Commit
·
fc9c13b
1
Parent(s):
bb4be18
Upload 17 files
Browse files- extract_news/1_extract_rss.py +149 -0
- extract_news/2_extract_news.py +89 -0
- extract_news/3_extract_news_txt.py +323 -0
- extract_news/4_extract_url_news.py +107 -0
- extract_news/README.md +104 -0
- extract_news/config.py +9 -0
- extract_news/database.sql +262 -0
- extract_news/old/1_extract_rss.php +149 -0
- extract_news/old/2_extract_news.php +73 -0
- extract_news/old/3_extract_news_txt.php +386 -0
- extract_news/old/4_extract_news_url.php +99 -0
- extract_news/old/database.sql +256 -0
- extract_news/old/functions_mysqli.php +29 -0
- extract_news/utils.py +134 -0
extract_news/1_extract_rss.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
"""
|
4 |
+
Extract article URLs from the RSS
|
5 |
+
|
6 |
+
This script is designed to fetch and extract article URLs from the RSS feeds of various French media outlets.
|
7 |
+
The sources of these RSS feeds are stored in the `base_media` table of the database.
|
8 |
+
For each source, the script retrieves the RSS content, processes each entry, and stores the article URLs
|
9 |
+
into the database for further processing or analysis.
|
10 |
+
|
11 |
+
To install the necessary packages:
|
12 |
+
pip install aiohttp mysql-connector-python
|
13 |
+
|
14 |
+
Author : Guillaume Eckendoerffer
|
15 |
+
Date : 03-10-23
|
16 |
+
Repository : https://github.com/Eckendoerffer/TorchTrainerFlow/
|
17 |
+
https://huggingface.co/datasets/eckendoerffer/news_fr
|
18 |
+
"""
|
19 |
+
|
20 |
+
import hashlib
|
21 |
+
import xml.etree.ElementTree as ET
|
22 |
+
import aiohttp
|
23 |
+
import asyncio
|
24 |
+
import time, os, re
|
25 |
+
from config import DB_CONFIG
|
26 |
+
from utils import save_to_file, create_connection
|
27 |
+
|
28 |
+
path = os.getcwd()
|
29 |
+
|
30 |
+
def update_last_fetched(connection, id_source, last):
|
31 |
+
cursor = connection.cursor()
|
32 |
+
cursor.execute("UPDATE `base_media` SET `last`=%s WHERE `id`=%s LIMIT 1", (last, id_source))
|
33 |
+
|
34 |
+
def fetch_rss(url):
|
35 |
+
headers = {
|
36 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36",
|
37 |
+
"Accept-Language": "fr-FR;q=1.0",
|
38 |
+
"Accept-Encoding": "gzip, deflate",
|
39 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
40 |
+
"DNT": "1",
|
41 |
+
"Connection": "keep-alive",
|
42 |
+
"Upgrade-Insecure-Requests": "1"
|
43 |
+
}
|
44 |
+
|
45 |
+
loop = asyncio.get_event_loop()
|
46 |
+
return loop.run_until_complete(fetch_rss_async(url, headers))
|
47 |
+
|
48 |
+
async def fetch_rss_async(url, headers):
|
49 |
+
async with aiohttp.ClientSession() as session:
|
50 |
+
async with session.get(url, headers=headers) as resp:
|
51 |
+
if resp.status == 200:
|
52 |
+
return await resp.text()
|
53 |
+
|
54 |
+
def check_url(connection, id_source, url):
|
55 |
+
global nb
|
56 |
+
for pattern in ['#', '?utm', '</loc>', '</url>']:
|
57 |
+
url = url.split(pattern)[0]
|
58 |
+
url = url.replace('<loc>', '')
|
59 |
+
url = url.replace('<url>', '')
|
60 |
+
key = hashlib.md5(url.encode()).hexdigest()
|
61 |
+
nb += 1
|
62 |
+
|
63 |
+
cursor = connection.cursor()
|
64 |
+
cursor.execute("SELECT `id` FROM `base_news` WHERE `key_media`=%s OR `url` LIKE %s LIMIT 1", (key, url + "%"))
|
65 |
+
nb_base = cursor.fetchone()
|
66 |
+
|
67 |
+
if url and not nb_base:
|
68 |
+
cursor.execute("INSERT INTO `base_news` (`key_media`, `media`, `url`, `link`, `step`) VALUES (%s, %s, %s, '0', '0')", (key, id_source, url))
|
69 |
+
|
70 |
+
def process_rss_content(connection, content, id_source):
|
71 |
+
global nb
|
72 |
+
nb = 0
|
73 |
+
try:
|
74 |
+
root = ET.fromstring(content)
|
75 |
+
except ET.ParseError as e:
|
76 |
+
return
|
77 |
+
|
78 |
+
# First attempt: Process each item in the channel
|
79 |
+
channel = root.find('channel')
|
80 |
+
if channel is not None:
|
81 |
+
for entry in root.find('channel').findall('item'):
|
82 |
+
url = entry.find('link').text.strip()
|
83 |
+
for pattern in ['#', '?utm', '?xtor']:
|
84 |
+
url = url.split(pattern)[0]
|
85 |
+
key = hashlib.md5(url.encode()).hexdigest()
|
86 |
+
nb += 1
|
87 |
+
|
88 |
+
cursor = connection.cursor()
|
89 |
+
cursor.execute("SELECT `id` FROM `base_news` WHERE `key_media`=%s OR `url` LIKE %s LIMIT 1", (key, url + "%"))
|
90 |
+
nb_base = cursor.fetchone()
|
91 |
+
|
92 |
+
if url and not nb_base:
|
93 |
+
cursor.execute("INSERT INTO `base_news` (`key_media`, `media`, `url`, `link`, `step`) VALUES (%s, %s, %s, '0', '0')", (key, id_source, url))
|
94 |
+
|
95 |
+
# Second attempt
|
96 |
+
if nb == 0:
|
97 |
+
for entry in root:
|
98 |
+
url =''
|
99 |
+
loc_element = entry.find('loc')
|
100 |
+
url_element = entry.find('url')
|
101 |
+
|
102 |
+
if loc_element is not None and loc_element.text is not None:
|
103 |
+
url = loc_element.text.strip()
|
104 |
+
|
105 |
+
elif url_element is not None and url_element.text is not None:
|
106 |
+
url = url_element.text.strip()
|
107 |
+
|
108 |
+
if url: check_url(connection, id_source, url)
|
109 |
+
|
110 |
+
if nb == 0:
|
111 |
+
links = re.findall(r'<url>(.*?)<\/url>', content)
|
112 |
+
for url in links:
|
113 |
+
check_url(connection, id_source, url)
|
114 |
+
|
115 |
+
if nb:
|
116 |
+
cursor = connection.cursor()
|
117 |
+
cursor.execute("SELECT `id` FROM `base_news` WHERE `media` = %s", (id_source,))
|
118 |
+
cursor.fetchall()
|
119 |
+
nb_base_news = cursor.rowcount
|
120 |
+
cursor.execute("UPDATE `base_media` SET `nb`=%s WHERE `id`=%s LIMIT 1", (nb_base_news, id_source))
|
121 |
+
|
122 |
+
def main():
|
123 |
+
global nb
|
124 |
+
nb = 0
|
125 |
+
connection = create_connection(DB_CONFIG)
|
126 |
+
cursor = connection.cursor(dictionary=True)
|
127 |
+
|
128 |
+
cursor.execute("SELECT `id`, `url`, `last` FROM `base_media` ORDER By `last`")
|
129 |
+
all_records = cursor.fetchall()
|
130 |
+
|
131 |
+
for record in all_records:
|
132 |
+
id_source = record['id']
|
133 |
+
url = record['url'].strip()
|
134 |
+
last_update = record['last']
|
135 |
+
|
136 |
+
if last_update + 3600 > time.time():
|
137 |
+
break
|
138 |
+
|
139 |
+
update_last_fetched(connection, id_source, int(time.time()))
|
140 |
+
data = fetch_rss(url)
|
141 |
+
if data.strip():
|
142 |
+
file_path = os.path.join(path, "sources", "rss", f"{id_source}.txt")
|
143 |
+
save_to_file(file_path, data)
|
144 |
+
process_rss_content(connection, data, id_source)
|
145 |
+
print(f"{id_source} # ({nb}) {url} ")
|
146 |
+
connection.close()
|
147 |
+
|
148 |
+
if __name__ == "__main__":
|
149 |
+
main()
|
extract_news/2_extract_news.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
"""
|
4 |
+
News source extractor:
|
5 |
+
|
6 |
+
This script is designed to extract the content of news articles from various French media sources.
|
7 |
+
The URLs of these articles are retrieved from the `base_news` table, where articles marked with
|
8 |
+
a `step` value of '0' are pending extraction.
|
9 |
+
|
10 |
+
To install the necessary packages:
|
11 |
+
pip install aiohttp mysql-connector-python
|
12 |
+
|
13 |
+
Once extracted, the content of each article is saved locally for further processing. This separation
|
14 |
+
of content fetching and processing is intentional to optimize resource management.
|
15 |
+
|
16 |
+
The script operates in batches, processing a defined number of entries (`NB_BY_STEP`) at a time.
|
17 |
+
After extraction, the `step` value of the processed articles is updated to '1' to indicate completion.
|
18 |
+
|
19 |
+
For performance monitoring, the script outputs the processed article IDs, URLs, and calculates the average
|
20 |
+
processing time per article.
|
21 |
+
|
22 |
+
Author : Guillaume Eckendoerffer
|
23 |
+
Date : 02-10-23
|
24 |
+
Repository : https://github.com/Eckendoerffer/TorchTrainerFlow/
|
25 |
+
https://huggingface.co/datasets/eckendoerffer/news_fr
|
26 |
+
"""
|
27 |
+
|
28 |
+
import asyncio
|
29 |
+
import aiohttp
|
30 |
+
import time, os
|
31 |
+
from config import DB_CONFIG
|
32 |
+
from utils import create_connection, mysqli_return_number, save_to_file
|
33 |
+
|
34 |
+
NB_BY_STEP = 20
|
35 |
+
path = os.getcwd()
|
36 |
+
|
37 |
+
async def fetch_and_save(url, id_source):
|
38 |
+
time_start_item = time.time()
|
39 |
+
try:
|
40 |
+
async with aiohttp.ClientSession() as session:
|
41 |
+
async with session.get(url, timeout=10) as response:
|
42 |
+
byte_content = await response.read()
|
43 |
+
try:
|
44 |
+
text_content = byte_content.decode('utf-8')
|
45 |
+
except UnicodeDecodeError:
|
46 |
+
text_content = byte_content.decode('ISO-8859-1')
|
47 |
+
|
48 |
+
save_to_file(f"{path}/sources/html_news/{id_source}.txt", text_content)
|
49 |
+
time_end_item = time.time()
|
50 |
+
print(f'{id_source}) {time_end_item-time_start_item:.5f} {url}')
|
51 |
+
except aiohttp.client_exceptions.TooManyRedirects:
|
52 |
+
print(f"Too many redirects for URL: {url}")
|
53 |
+
except aiohttp.client_exceptions.ClientConnectorError:
|
54 |
+
print(f"Failed to connect to URL: {url}")
|
55 |
+
except Exception as e:
|
56 |
+
print(f"Unexpected error for URL {url}: {str(e)}")
|
57 |
+
|
58 |
+
async def main():
|
59 |
+
connection = create_connection(DB_CONFIG)
|
60 |
+
while True:
|
61 |
+
time_start = time.time()
|
62 |
+
cursor = connection.cursor()
|
63 |
+
cursor.execute(f"SELECT `id`, `url` FROM `base_news` WHERE `step`='0' ORDER BY RAND() LIMIT {NB_BY_STEP}")
|
64 |
+
rows = cursor.fetchall()
|
65 |
+
cursor.close()
|
66 |
+
if not rows:
|
67 |
+
break
|
68 |
+
tasks = []
|
69 |
+
for row in rows:
|
70 |
+
id_source, url = row
|
71 |
+
cursor = connection.cursor()
|
72 |
+
cursor.execute(f"UPDATE `base_news` SET `step`='1' WHERE `id`='{id_source}' LIMIT 1")
|
73 |
+
cursor.close()
|
74 |
+
tasks.append(fetch_and_save(url.strip(), id_source))
|
75 |
+
|
76 |
+
await asyncio.gather(*tasks)
|
77 |
+
|
78 |
+
nb_base = mysqli_return_number(connection, "SELECT COUNT(`id`) FROM `base_news` WHERE `step`='0'")
|
79 |
+
time_elapsed = time.time() - time_start
|
80 |
+
time_per_item = time_elapsed / NB_BY_STEP
|
81 |
+
print(f"Remaining: {nb_base} - Time: {time_per_item:.3f}s/url")
|
82 |
+
#if nb_base < 100: time.sleep(600)
|
83 |
+
|
84 |
+
connection.close()
|
85 |
+
|
86 |
+
if __name__ == "__main__":
|
87 |
+
asyncio.run(main())
|
88 |
+
|
89 |
+
|
extract_news/3_extract_news_txt.py
ADDED
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
"""
|
4 |
+
News article text extractor
|
5 |
+
|
6 |
+
This script extracts the text from locally-stored news articles. The main goal is
|
7 |
+
to retrieve clean text with minimal external elements, such as user menus, article lists,
|
8 |
+
and advertisements.
|
9 |
+
|
10 |
+
To install the necessary packages:
|
11 |
+
pip install mysql-connector-python chardet colorama pyquery
|
12 |
+
|
13 |
+
After completing this step, you can use the Python script located at /dataset/2_cleaning_txt.py
|
14 |
+
to standardize the text for your dataset.
|
15 |
+
|
16 |
+
Note:
|
17 |
+
RSS feed links for media sources, as well as the HTML structure of media pages, tend to change
|
18 |
+
and evolve regularly. It's crucial to regularly check the output per media source and adjust
|
19 |
+
the parsing process to ensure high-quality text extraction and to address potential changes
|
20 |
+
in RSS feed URLs.
|
21 |
+
|
22 |
+
Author : Guillaume Eckendoerffer
|
23 |
+
Date : 29-09-23
|
24 |
+
Repository : https://github.com/Eckendoerffer/TorchTrainerFlow/
|
25 |
+
https://huggingface.co/datasets/eckendoerffer/news_fr
|
26 |
+
"""
|
27 |
+
|
28 |
+
import chardet
|
29 |
+
import time, os, re, html, json, hashlib
|
30 |
+
from colorama import Fore, init
|
31 |
+
from pyquery import PyQuery as pq
|
32 |
+
from config import DB_CONFIG
|
33 |
+
from utils import create_connection, get_file_content, save_to_file, clean_text, decode_unicode_escapes, decode_content
|
34 |
+
|
35 |
+
index_id = 935146
|
36 |
+
stop_id = 981462
|
37 |
+
path = os.getcwd()
|
38 |
+
init(autoreset=True)
|
39 |
+
|
40 |
+
connection = create_connection(DB_CONFIG)
|
41 |
+
cursor = connection.cursor()
|
42 |
+
query = "SELECT `key_title` FROM `base_news` WHERE `key_title` != ''"
|
43 |
+
cursor.execute(query)
|
44 |
+
keys = cursor.fetchall()
|
45 |
+
formatted_keys = "|".join([key[0] for key in keys]) + "|"
|
46 |
+
|
47 |
+
while True:
|
48 |
+
id_source =''
|
49 |
+
next_id = index_id + 1
|
50 |
+
time_start = time.time()
|
51 |
+
with connection.cursor() as cursor:
|
52 |
+
cursor = connection.cursor(dictionary=True)
|
53 |
+
cursor.execute(f"SELECT `id`, `url`, `media`, `key_title` FROM `base_news` WHERE `id`='{index_id}' LIMIT 1")
|
54 |
+
row = cursor.fetchone()
|
55 |
+
if row:
|
56 |
+
id_source = row["id"]
|
57 |
+
id_media = row["media"]
|
58 |
+
key_title = row["key_title"]
|
59 |
+
url = row["url"].strip()
|
60 |
+
|
61 |
+
if key_title.strip():
|
62 |
+
index_id = next_id
|
63 |
+
continue
|
64 |
+
|
65 |
+
if id_source and id_source > stop_id:
|
66 |
+
break
|
67 |
+
|
68 |
+
# Retrieve HTML content from the file
|
69 |
+
html_content = ''
|
70 |
+
content=''
|
71 |
+
title=''
|
72 |
+
file_path = os.path.join(path, "sources", "html_news", f"{id_source}.txt")
|
73 |
+
html_content = get_file_content(file_path)
|
74 |
+
|
75 |
+
if '/replay' in url or not html_content:
|
76 |
+
index_id = next_id
|
77 |
+
continue
|
78 |
+
|
79 |
+
len_source = len(html_content)
|
80 |
+
|
81 |
+
# encoding
|
82 |
+
if isinstance(html_content, str):
|
83 |
+
html_content_bytes = html_content.encode('utf-8')
|
84 |
+
else:
|
85 |
+
html_content_bytes = html_content
|
86 |
+
decoded_content = decode_content(html_content_bytes)
|
87 |
+
if decoded_content is None:
|
88 |
+
charset_result = chardet.detect(html_content_bytes)
|
89 |
+
current_encoding = charset_result['encoding']
|
90 |
+
try:
|
91 |
+
html_content = html_content_bytes.decode(current_encoding)
|
92 |
+
except Exception as e:
|
93 |
+
print(Fore.WHITE + f"Error: {e}")
|
94 |
+
index_id = next_id
|
95 |
+
continue
|
96 |
+
else:
|
97 |
+
html_content = decoded_content
|
98 |
+
|
99 |
+
len_or = len(html_content)
|
100 |
+
|
101 |
+
# Use pyquery to parse the HTML
|
102 |
+
try:
|
103 |
+
doc = pq(html_content)
|
104 |
+
except Exception as e:
|
105 |
+
print(Fore.WHITE + f"({id_source}) Error parsing HTML: {e} {url}")
|
106 |
+
index_id = next_id
|
107 |
+
continue
|
108 |
+
|
109 |
+
# Extracting the title
|
110 |
+
if title.strip() =='':
|
111 |
+
title = html.unescape(doc('h1:first').text())
|
112 |
+
if title.strip() =='':
|
113 |
+
index_id = next_id
|
114 |
+
cursor = connection.cursor()
|
115 |
+
cursor.execute("UPDATE `base_media` SET `deleted`=`deleted`+1 WHERE `id`=%s LIMIT 1", (id_media,))
|
116 |
+
continue
|
117 |
+
|
118 |
+
extract_method = 0
|
119 |
+
# Extracting the text from "articleBody": ld json
|
120 |
+
match = re.search(r'"articleBody"\s*:\s*"([^"]+)"', html_content)
|
121 |
+
if match:
|
122 |
+
content = html.unescape(match.group(1))
|
123 |
+
if content.strip():
|
124 |
+
extract_method = 1
|
125 |
+
try:
|
126 |
+
content = json.loads(f'"{content}"')
|
127 |
+
except json.JSONDecodeError:
|
128 |
+
content = decode_unicode_escapes(content)
|
129 |
+
|
130 |
+
# Extracting the text from <article> tag
|
131 |
+
if not extract_method or len(content) < 100:
|
132 |
+
p_elements = doc('article p')
|
133 |
+
if not p_elements:
|
134 |
+
p_elements = doc('div.Body p')
|
135 |
+
if not p_elements:
|
136 |
+
p_elements = doc('div.post-body p')
|
137 |
+
if not p_elements:
|
138 |
+
p_elements = doc('div.article_content p')
|
139 |
+
if not p_elements:
|
140 |
+
p_elements = doc('div.article__text p')
|
141 |
+
if not p_elements:
|
142 |
+
p_elements = doc('div.article-description p')
|
143 |
+
if not p_elements:
|
144 |
+
p_elements = doc('div.mainBody p')
|
145 |
+
if not p_elements:
|
146 |
+
p_elements = doc('section.article-section p')
|
147 |
+
if not p_elements:
|
148 |
+
p_elements = doc('div.article p')
|
149 |
+
|
150 |
+
for p in p_elements:
|
151 |
+
html_element = pq(p)
|
152 |
+
html_content += f" {html_element.html().strip()} "
|
153 |
+
|
154 |
+
if ".futura-sciences.com" in url:
|
155 |
+
html_element.find('a').remove()
|
156 |
+
content += f" {html.unescape(html_element.text().strip())} "
|
157 |
+
if content.strip(): extract_method = 2
|
158 |
+
|
159 |
+
len_text = len(content)
|
160 |
+
|
161 |
+
# Adding a space after punctuation and various deletions
|
162 |
+
content = content.replace('\r', ' ').replace('\n', ' ')
|
163 |
+
remove_phrases = ['.', '?', '!', ';', '!', '»', ']']
|
164 |
+
for phrase in remove_phrases:
|
165 |
+
content = content.replace(phrase, phrase + ' ')
|
166 |
+
content = content.replace(html.unescape(' '), ' ')
|
167 |
+
content = re.sub(r'\s{2,}', ' ', content)
|
168 |
+
content = re.sub(r'À lire aussi.{1,200}?»', ' ', content)
|
169 |
+
content = re.sub(r'Temps de Lecture.{1,20}? Fiche', ' ', content)
|
170 |
+
content = re.sub(r'Temps de Lecture.{1,20}? min.', ' ', content)
|
171 |
+
|
172 |
+
# Media-specific cutting rules
|
173 |
+
if ".elle.fr" in url and "sur 5" in content:
|
174 |
+
content = re.sub(r'Note :.{13,45}? sur 5', ' ', content)
|
175 |
+
content = content.replace(content[content.find(" sur 5 "):], ' ')
|
176 |
+
|
177 |
+
if ".latribune.fr" in url:
|
178 |
+
content = content.replace("Partager :", ' ')
|
179 |
+
|
180 |
+
removePhrasesEnd = [
|
181 |
+
'Sur le même sujet',
|
182 |
+
'Sur lemême thème',
|
183 |
+
'Nos articles à lire aussi',
|
184 |
+
'Suivez toute l’actualité de vos villes',
|
185 |
+
'En direct',
|
186 |
+
"J'ai déjà un compte",
|
187 |
+
'> Ecoutez',
|
188 |
+
"Lire aussi >>",
|
189 |
+
'Courrier international',
|
190 |
+
'Vous avez trouvé une erreur?',
|
191 |
+
'Il vous reste',
|
192 |
+
'Partager',
|
193 |
+
"Suivez-nous",
|
194 |
+
'Newsletter',
|
195 |
+
'Abonnez-vous',
|
196 |
+
'1€ le premier mois',
|
197 |
+
'Votre France Bleu',
|
198 |
+
'Soyez le premier à commenter cet article',
|
199 |
+
'Pour rester informé(e)',
|
200 |
+
'Un site du groupe',
|
201 |
+
"Cet article est réservé aux abonnés",
|
202 |
+
"Recevez chaque vendredi l'essentiel",
|
203 |
+
"Suivez toute l'actualité de ZDNet",
|
204 |
+
"Suivez-nous sur les résaux sociaux",
|
205 |
+
". par ",
|
206 |
+
"Le résumé de la semaine",
|
207 |
+
"ACTUELLEMENT EN KIOSQUE",
|
208 |
+
" L’actualité par la rédaction de",
|
209 |
+
"Gratis onbeperkt",
|
210 |
+
"Débloquez immédiatement cet article",
|
211 |
+
"À voir également",
|
212 |
+
"null null null ",
|
213 |
+
'Du lundi au vendredi, à 19h',
|
214 |
+
"La rédaction de La Tribune",
|
215 |
+
"Restez toujours informé: suivez-nous sur Google Actualités",
|
216 |
+
"Du lundi au vendredi, votre rendez-vous",
|
217 |
+
"Enregistrer mon nom, mon e-mail",
|
218 |
+
"Mot de passe oublié",
|
219 |
+
"accès à ce contenu",
|
220 |
+
"En cliquant sur",
|
221 |
+
'(function',
|
222 |
+
]
|
223 |
+
# Remove sentences at the end
|
224 |
+
for phrase in removePhrasesEnd:
|
225 |
+
if phrase in content:
|
226 |
+
content = content.split(phrase, 1)[0]
|
227 |
+
|
228 |
+
removePhrases = [
|
229 |
+
"Inscrivez-vous pour recevoir les newsletters de la Rép' dans votre boîte mail",
|
230 |
+
"TF1 INFO",
|
231 |
+
"Sujet TF1 Info",
|
232 |
+
"Sujet JT LCI",
|
233 |
+
"TF1 Info ",
|
234 |
+
"JT 20h WE ",
|
235 |
+
"JT 20h Semaine ",
|
236 |
+
"Source :",
|
237 |
+
"Inscrivez-vous aux newsletters de la RTBF Tous les sujets de l'article",
|
238 |
+
"Pour voir ce contenu, connectez-vous gratuitement",
|
239 |
+
">> LIRE AUSSI",
|
240 |
+
"À LIRE AUSSI",
|
241 |
+
"A lire aussi >> ",
|
242 |
+
"» LIRE AUSSI -",
|
243 |
+
" → À LIRE.",
|
244 |
+
"À voir également",
|
245 |
+
"Image d'illustration -",
|
246 |
+
"Le média de la vie locale ",
|
247 |
+
"Les plus lus.",
|
248 |
+
"Ce live est à présent terminé.",
|
249 |
+
" . -",
|
250 |
+
"[…]",
|
251 |
+
"[.]",
|
252 |
+
"(…)",
|
253 |
+
"(.)",
|
254 |
+
"©",
|
255 |
+
"Tous droits réservés",
|
256 |
+
" sur TF1",
|
257 |
+
"Avec AFP",
|
258 |
+
" AFP /",
|
259 |
+
"/ AFP ",
|
260 |
+
". AFP",
|
261 |
+
" BELGA /",
|
262 |
+
"GETTY",
|
263 |
+
"Getty Images",
|
264 |
+
"→ EXPLICATION",
|
265 |
+
"→ LES FAITS",
|
266 |
+
"→",
|
267 |
+
"À lire aussi",
|
268 |
+
"EN RÉSUMÉ",
|
269 |
+
"•",
|
270 |
+
"►►► ",
|
271 |
+
"► Écoutez l'entièreté de ce podcast ci-dessus",
|
272 |
+
"► Pour écouter ce podcast , abonnez-vous",
|
273 |
+
"►"
|
274 |
+
]
|
275 |
+
|
276 |
+
# Remove terms
|
277 |
+
for phrase in removePhrases:
|
278 |
+
content = content.replace(phrase, '.')
|
279 |
+
|
280 |
+
# Replace sequences of characters
|
281 |
+
content = content.replace(',.', '.')
|
282 |
+
content = content.replace('.,', '.')
|
283 |
+
content = re.sub(r'\.{2,}', '.', content)
|
284 |
+
content = re.sub(r'\s{2,}', ' ', content)
|
285 |
+
content = re.sub(r'-{2,}', '-', content)
|
286 |
+
content = re.sub(r'__{2,}', '_', content)
|
287 |
+
content = re.sub(r'Publié le\s?:? \d{2} ?\/ ?\d{2} ?\/ ?\d{4}( à \d{2}h\d{2})?', '', content)
|
288 |
+
content = re.sub(r'Mis à jour le \d{1,2} \w+ \. \d{4}', '', content)
|
289 |
+
matches = [match.group() for match in re.finditer(r'(\d{2}:\d{2})?Modifié le : \d{2}/\d{2}/\d{4}( - \d{2}:\d{2})?', content) if len(match.group()) <= 38]
|
290 |
+
for match in matches:
|
291 |
+
content = content.replace(match, ' ')
|
292 |
+
|
293 |
+
# Format the content for the txt file into the 'add' variable
|
294 |
+
content = re.sub(r'<.*?>', '', content)
|
295 |
+
add = f"{title}. "
|
296 |
+
if len(content) > 160:
|
297 |
+
add += f"{content}."
|
298 |
+
|
299 |
+
add = clean_text(add)
|
300 |
+
key = hashlib.md5(title.encode()).hexdigest()
|
301 |
+
nb_base = formatted_keys.count(f'{key}|')
|
302 |
+
|
303 |
+
# Display
|
304 |
+
test =''
|
305 |
+
color = Fore.GREEN if len(content) > 200 else Fore.WHITE
|
306 |
+
if len(content) > 200 and nb_base:
|
307 |
+
color = Fore.CYAN
|
308 |
+
test = '' #f"[{title}]"
|
309 |
+
|
310 |
+
if len(content) > 200 and not nb_base:
|
311 |
+
cursor = connection.cursor()
|
312 |
+
cursor.execute("UPDATE `base_news` SET `key_title`=%s WHERE `id`=%s LIMIT 1", (key, id_source))
|
313 |
+
cursor = connection.cursor()
|
314 |
+
cursor.execute("UPDATE `base_media` SET `add`=`add`+1 WHERE `id`=%s LIMIT 1", (id_media,))
|
315 |
+
formatted_keys = f'{formatted_keys}{key}|'
|
316 |
+
save_to_file(f"{path}/sources/txt_news/{id_source}.txt", add)
|
317 |
+
elif not nb_base:
|
318 |
+
cursor = connection.cursor()
|
319 |
+
cursor.execute("UPDATE `base_media` SET `deleted`=`deleted`+1 WHERE `id`=%s LIMIT 1", (id_media,))
|
320 |
+
|
321 |
+
elapsed_time = time.time() - time_start
|
322 |
+
print(color + f"{id_source:8}) ({extract_method:1}) [{elapsed_time:.3f}] [{len_source:7}{len_text:7}{len(content):7}{len(title):4} ] {url} {test}")
|
323 |
+
index_id = next_id
|
extract_news/4_extract_url_news.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
"""
|
4 |
+
News links extractor
|
5 |
+
|
6 |
+
Extracts and stores relevant links from local French online news articles.
|
7 |
+
|
8 |
+
pip install beautifulsoup4 mysql-connector-python colorama
|
9 |
+
|
10 |
+
Author : Guillaume Eckendoerffer
|
11 |
+
Date : 28-09-23
|
12 |
+
Repository : https://github.com/Eckendoerffer/TorchTrainerFlow/
|
13 |
+
"""
|
14 |
+
|
15 |
+
import os, hashlib
|
16 |
+
from bs4 import BeautifulSoup
|
17 |
+
from colorama import Fore, init
|
18 |
+
from config import DB_CONFIG
|
19 |
+
from utils import create_connection, get_file_content
|
20 |
+
|
21 |
+
connection = create_connection(DB_CONFIG)
|
22 |
+
cursor = connection.cursor()
|
23 |
+
query = "SELECT `key_media` FROM `base_news` WHERE `key_media` != ''"
|
24 |
+
cursor.execute(query)
|
25 |
+
keys = cursor.fetchall()
|
26 |
+
formatted_keys = "|".join([key[0] for key in keys]) + "|"
|
27 |
+
|
28 |
+
init(autoreset=True)
|
29 |
+
|
30 |
+
def get_dom_path(url):
|
31 |
+
from urllib.parse import urlparse
|
32 |
+
parsed_url = urlparse(url)
|
33 |
+
return f"{parsed_url.scheme}://{parsed_url.netloc}"
|
34 |
+
|
35 |
+
def process_news_source(id_source, url_source, id_media):
|
36 |
+
global formatted_keys
|
37 |
+
|
38 |
+
dom = get_dom_path(url_source)
|
39 |
+
cursor.execute(f"UPDATE `base_news` SET `link`='1' WHERE `id`='{id_source}' LIMIT 1")
|
40 |
+
connection.commit()
|
41 |
+
|
42 |
+
file_path = f"sources/html_news/{id_source}.txt"
|
43 |
+
if os.path.exists(file_path):
|
44 |
+
html_content = get_file_content(file_path)
|
45 |
+
else:
|
46 |
+
return
|
47 |
+
|
48 |
+
print(f"{id_source} {url_source} {id_media} ({len(html_content)})")
|
49 |
+
|
50 |
+
soup = BeautifulSoup(html_content, 'html.parser')
|
51 |
+
nb_add = 0
|
52 |
+
for link in soup.find_all('a'):
|
53 |
+
url = link.get('href')
|
54 |
+
if url is None:
|
55 |
+
continue
|
56 |
+
url = url.split("#")[0]
|
57 |
+
url = url.split("?")[0]
|
58 |
+
|
59 |
+
if not url:
|
60 |
+
continue
|
61 |
+
if not "//" in url:
|
62 |
+
url = f"{dom}/{url}" if url[0] != '/' else f"{dom}{url}"
|
63 |
+
elif "http" not in url:
|
64 |
+
url = 'https:' + url
|
65 |
+
if not url.startswith(("http://", "https://")) or url.count(' ') or url.count('%') or url.count('\''):
|
66 |
+
continue
|
67 |
+
|
68 |
+
key = hashlib.md5(url.encode()).hexdigest()
|
69 |
+
nb_base_news = formatted_keys.count(f'{key}|')
|
70 |
+
|
71 |
+
if url.startswith(dom):
|
72 |
+
if nb_base_news:
|
73 |
+
#print(Fore.YELLOW + url)
|
74 |
+
continue
|
75 |
+
elif (
|
76 |
+
url.count("-") > 6 and
|
77 |
+
not any(substring in url for substring in ['replay', 'video', 'login', '/inloggen', '?redirect', '.jpg', '.png', 'mailto'])
|
78 |
+
):
|
79 |
+
print(Fore.GREEN + url)
|
80 |
+
insert_query = f"INSERT INTO `base_news` (`id`, `key_media`, `media`, `url`, `step`) VALUES (NULL, '{key}', '{id_media}', '{url}', '0');"
|
81 |
+
cursor.execute(insert_query)
|
82 |
+
connection.commit()
|
83 |
+
formatted_keys = f'{formatted_keys}{key}|'
|
84 |
+
nb_add += 1
|
85 |
+
else:
|
86 |
+
#print(Fore.RED + url)
|
87 |
+
continue
|
88 |
+
|
89 |
+
def process():
|
90 |
+
global formatted_keys
|
91 |
+
|
92 |
+
cursor = connection.cursor()
|
93 |
+
query = ("SELECT `id`, `url`, `media` FROM `base_news` WHERE `link`='0' AND `step` > 0 ORDER BY Rand() LIMIT 1000")
|
94 |
+
cursor.execute(query)
|
95 |
+
rows = cursor.fetchall()
|
96 |
+
|
97 |
+
if not rows:
|
98 |
+
print('No unprocessed news source found.')
|
99 |
+
|
100 |
+
for row in rows:
|
101 |
+
id_source, url_source, id_media = row
|
102 |
+
process_news_source(id_source, url_source, id_media)
|
103 |
+
|
104 |
+
while True:
|
105 |
+
process()
|
106 |
+
|
107 |
+
|
extract_news/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-3.0
|
3 |
+
task_categories:
|
4 |
+
- text-generation
|
5 |
+
language:
|
6 |
+
- fr
|
7 |
+
tags:
|
8 |
+
- news
|
9 |
+
- media
|
10 |
+
- Press
|
11 |
+
size_categories:
|
12 |
+
- 100K<n<1M
|
13 |
+
---
|
14 |
+
# NEWS FR
|
15 |
+
There is an open-access [dataset on BnF / Gallica](https://transfert.bnf.fr/link/3a04ea3f-dbe8-4a4a-a302-913a89c3a7a8) comprising nearly a hundred newspapers from the print media spanning almost 100 years.
|
16 |
+
Unfortunately, for this dataset, only 85% of the text is transcribed accurately.
|
17 |
+
|
18 |
+
## DATASET
|
19 |
+
This dataset compiles 1M online articles from nearly 100 Francophone media outlets. This dataset is intended for research purposes and non-commercial use. It includes 1,140,000 lines for model training, and 63,500 lines for the test and validation files.
|
20 |
+
|
21 |
+
Included with this dataset are scripts to extract and process the article text from the same sources. The script is somewhat rough around the edges, but it is functional and commented.
|
22 |
+
|
23 |
+
### Format
|
24 |
+
|
25 |
+
- **Type**: Text
|
26 |
+
- **File Extension**: `.txt`
|
27 |
+
|
28 |
+
The text has been standardized for consistent formatting and line length. Additionally, the dataset has been filtered using the `langid` library to include only text in French.
|
29 |
+
|
30 |
+
### Structure
|
31 |
+
|
32 |
+
The dataset is divided into the following splits:
|
33 |
+
|
34 |
+
- `train.txt`: 2.2 GB - 1,140,000 rows - 90%
|
35 |
+
- `test.txt` : 122 MB - 63,500 rows - 5%
|
36 |
+
- `valid.txt`: 122 MB - 63,500 rows - 5%
|
37 |
+
|
38 |
+
### Exploring the Dataset
|
39 |
+
|
40 |
+
You can use the `explore_dataset.py` script to explore the dataset by randomly displaying a certain number of lines from it. The script creates and saves an index based on the line breaks, enabling faster data retrieval and display.
|
41 |
+
|
42 |
+
### Additional Information
|
43 |
+
|
44 |
+
This dataset is a subset of a larger 10GB French dataset, which also contains several thousand books and theses in French, Wikipedia, as well as several hundred thousand Francophone news articles.
|
45 |
+
|
46 |
+
## EXTRACT NEWS FR
|
47 |
+
|
48 |
+
The "NEWS FR" module allows for the extraction of online press articles from over a hundred different sources.
|
49 |
+
|
50 |
+
## Installation
|
51 |
+
|
52 |
+
To set up the module, follow the steps below:
|
53 |
+
|
54 |
+
1. **Database Setup**:
|
55 |
+
- Create a database and incorporate the two tables present in `database.sql`.
|
56 |
+
|
57 |
+
2. **Database Configuration**:
|
58 |
+
- Update your MySQL connection information in the `config.py` file.
|
59 |
+
|
60 |
+
3. **Dependencies Installation**:
|
61 |
+
- Install it using pip install:
|
62 |
+
```
|
63 |
+
pip install aiohttp mysql-connector-python beautifulsoup4 chardet colorama pyquery
|
64 |
+
```
|
65 |
+
|
66 |
+
## Usage
|
67 |
+
|
68 |
+
### 1_extract_rss.py:
|
69 |
+
|
70 |
+
This script fetches RSS feeds from various media outlets and adds URLs for further extraction.
|
71 |
+
|
72 |
+
```bash
|
73 |
+
python 1_extract_rss.py
|
74 |
+
```
|
75 |
+
|
76 |
+
### 2_extract_news.py:
|
77 |
+
|
78 |
+
This script retrieves the sources of articles for subsequent local processing.
|
79 |
+
|
80 |
+
```bash
|
81 |
+
python 2_extract_news.py
|
82 |
+
```
|
83 |
+
|
84 |
+
### 3_extract_news_txt.py:
|
85 |
+
|
86 |
+
This script extracts the text content of press articles and saves it (title + description + text) to a `.txt` file.
|
87 |
+
|
88 |
+
```bash
|
89 |
+
python 3_extract_news_txt.py
|
90 |
+
```
|
91 |
+
After completing this step, you can use the Python script located at /dataset/2_cleaning_txt.py to standardize the text for your dataset.
|
92 |
+
|
93 |
+
### 4_extract_news_url.py:
|
94 |
+
|
95 |
+
This script allows for the extraction of links to other articles from local article sources. This ensures swift retrieval of numerous past articles, as opposed to fetching only the most recent ones.
|
96 |
+
|
97 |
+
```bash
|
98 |
+
php 4_extract_news_url.py
|
99 |
+
```
|
100 |
+
|
101 |
+
After using this script, you'll need to run 2_extract_news.py again to retrieve the sources of the new articles, as well as 3_extract_news_txt.py to extract the text from these articles.
|
102 |
+
|
103 |
+
---
|
104 |
+
|
extract_news/config.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Database configuration
|
3 |
+
|
4 |
+
DB_CONFIG = {
|
5 |
+
"user": "[user]",
|
6 |
+
"password": "[passwd]",
|
7 |
+
"host": "[host]",
|
8 |
+
"database": "[database]"
|
9 |
+
}
|
extract_news/database.sql
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
--
|
3 |
+
-- Structure of the `base_media` table
|
4 |
+
--
|
5 |
+
|
6 |
+
CREATE TABLE IF NOT EXISTS `base_media` (
|
7 |
+
`id` int NOT NULL AUTO_INCREMENT,
|
8 |
+
`url` varchar(255) NOT NULL,
|
9 |
+
`nb` int NOT NULL,
|
10 |
+
`last` int NOT NULL,
|
11 |
+
PRIMARY KEY (`id`)
|
12 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
13 |
+
|
14 |
+
--
|
15 |
+
-- Data from `base_media` table
|
16 |
+
--
|
17 |
+
|
18 |
+
INSERT INTO `base_media` (`id`, `url`, `nb`, `last`) VALUES
|
19 |
+
(1, 'https://www.lemonde.fr/rss/une.xml', 0, 0),
|
20 |
+
(2, 'https://www.liberation.fr/arc/outboundfeeds/collection/accueil-une/?outputType=xml', 0, 0),
|
21 |
+
(3, 'https://www.lemonde.fr/international/rss_full.xml', 0, 0),
|
22 |
+
(4, 'https://www.lemonde.fr/europe/rss_full.xml', 0, 0),
|
23 |
+
(5, 'https://www.lemonde.fr/politique/rss_full.xml', 0, 0),
|
24 |
+
(6, 'https://www.lemonde.fr/economie/rss_full.xml', 0, 0),
|
25 |
+
(7, 'https://www.lemonde.fr/culture/rss_full.xml', 0, 0),
|
26 |
+
(8, 'https://www.lemonde.fr/sport/rss_full.xml', 0, 0),
|
27 |
+
(9, 'https://www.lemonde.fr/sciences/rss_full.xml', 0, 0),
|
28 |
+
(10, 'https://www.lemonde.fr/rss/en_continu.xml', 0, 0),
|
29 |
+
(11, 'https://www.numerama.com/feed/', 0, 0),
|
30 |
+
(12, 'https://www.bfmtv.com/rss/news-24-7/', 0, 0),
|
31 |
+
(13, 'https://www.bfmtv.com/rss/international/', 0, 0),
|
32 |
+
(14, 'https://www.bfmtv.com/rss/politique/', 0, 0),
|
33 |
+
(15, 'https://www.bfmtv.com/rss/sciences/', 0, 0),
|
34 |
+
(16, 'https://www.bfmtv.com/rss/police-justice/', 0, 0),
|
35 |
+
(17, 'https://www.bfmtv.com/rss/people/cinema/', 0, 0),
|
36 |
+
(18, 'https://www.bfmtv.com/rss/tech/', 0, 0),
|
37 |
+
(19, 'https://www.bfmtv.com/rss/economie/', 0, 0),
|
38 |
+
(20, 'https://www.bfmtv.com/rss/paris/', 0, 0),
|
39 |
+
(21, 'https://www.bfmtv.com/rss/lyon/', 0, 0),
|
40 |
+
(22, 'https://www.bfmtv.com/rss/grand-lille/', 0, 0),
|
41 |
+
(23, 'https://www.bfmtv.com/rss/grand-littoral/', 0, 0),
|
42 |
+
(24, 'https://www.bfmtv.com/rss/marseille/', 0, 0),
|
43 |
+
(25, 'https://www.bfmtv.com/rss/var/', 0, 0),
|
44 |
+
(26, 'https://www.bfmtv.com/rss/cote-d-azur/', 0, 0),
|
45 |
+
(27, 'https://www.bfmtv.com/rss/toulouse/', 0, 0),
|
46 |
+
(28, 'https://www.bfmtv.com/rss/bordeaux/', 0, 0),
|
47 |
+
(29, 'https://www.bfmtv.com/rss/brest/', 0, 0),
|
48 |
+
(30, 'https://www.bfmtv.com/rss/dijon/', 0, 0),
|
49 |
+
(31, 'https://www.bfmtv.com/rss/grenoble/', 0, 0),
|
50 |
+
(32, 'https://www.bfmtv.com/rss/la-rochelle/', 0, 0),
|
51 |
+
(33, 'https://www.bfmtv.com/rss/limoges/', 0, 0),
|
52 |
+
(34, 'https://www.bfmtv.com/rss/metz/', 0, 0),
|
53 |
+
(35, 'https://www.bfmtv.com/rss/montpellier/', 0, 0),
|
54 |
+
(36, 'https://www.bfmtv.com/rss/nancy/', 0, 0),
|
55 |
+
(37, 'https://www.bfmtv.com/rss/nantes/', 0, 0),
|
56 |
+
(38, 'https://www.bfmtv.com/rss/poitiers/', 0, 0),
|
57 |
+
(39, 'https://www.bfmtv.com/rss/reims/', 0, 0),
|
58 |
+
(40, 'https://www.bfmtv.com/rss/rennes/', 0, 0),
|
59 |
+
(41, 'https://www.bfmtv.com/rss/saint-etienne/', 0, 0),
|
60 |
+
(42, 'https://www.bfmtv.com/rss/strasbourg/', 0, 0),
|
61 |
+
(43, 'https://www.bfmtv.com/rss/tours/', 0, 0),
|
62 |
+
(44, 'https://www.cnews.fr/rss.xml', 0, 0),
|
63 |
+
(45, 'https://www.francetvinfo.fr/titres.rss', 0, 0),
|
64 |
+
(46, 'https://www.francetvinfo.fr/france.rss', 0, 0),
|
65 |
+
(47, 'https://www.francetvinfo.fr/politique.rss', 0, 0),
|
66 |
+
(48, 'https://www.francetvinfo.fr/societe.rss', 0, 0),
|
67 |
+
(49, 'https://www.francetvinfo.fr/faits-divers.rss', 0, 0),
|
68 |
+
(50, 'https://www.francetvinfo.fr/monde.rss', 0, 0),
|
69 |
+
(51, 'https://www.francetvinfo.fr/economie.rss', 0, 0),
|
70 |
+
(52, 'https://www.francetvinfo.fr/sports.rss', 0, 0),
|
71 |
+
(53, 'https://www.francetvinfo.fr/decouverte.rss', 0, 0),
|
72 |
+
(54, 'https://www.francetvinfo.fr/culture.rss', 0, 0),
|
73 |
+
(55, 'https://www.france24.com/fr/rss', 0, 0),
|
74 |
+
(56, 'https://www.france24.com/fr/europe/rss', 0, 0),
|
75 |
+
(57, 'https://www.france24.com/fr/france/rss', 0, 0),
|
76 |
+
(58, 'https://www.france24.com/fr/afrique/rss', 0, 0),
|
77 |
+
(59, 'https://www.france24.com/fr/moyen-orient/rss', 0, 0),
|
78 |
+
(60, 'https://www.france24.com/fr/ameriques/rss', 0, 0),
|
79 |
+
(61, 'https://www.france24.com/fr/asie-pacifique/rss', 0, 0),
|
80 |
+
(62, 'https://www.france24.com/fr/economie/rss', 0, 0),
|
81 |
+
(63, 'https://www.france24.com/fr/sports/rss', 0, 0),
|
82 |
+
(64, 'https://www.france24.com/fr/culture/rss', 0, 0),
|
83 |
+
(65, 'https://www.lefigaro.fr/rss/figaro_actualites.xml', 0, 0),
|
84 |
+
(66, 'https://www.lefigaro.fr/rss/figaro_politique.xml', 0, 0),
|
85 |
+
(67, 'https://www.lefigaro.fr/rss/figaro_elections.xml', 0, 0),
|
86 |
+
(68, 'https://www.lefigaro.fr/rss/figaro_international.xml', 0, 0),
|
87 |
+
(69, 'https://www.lefigaro.fr/rss/figaro_actualite-france.xml', 0, 0),
|
88 |
+
(70, 'https://www.lefigaro.fr/rss/figaro_sciences.xml', 0, 0),
|
89 |
+
(71, 'https://www.lefigaro.fr/rss/figaro_economie.xml', 0, 0),
|
90 |
+
(72, 'https://www.lefigaro.fr/rss/figaro_culture.xml', 0, 0),
|
91 |
+
(73, 'https://www.lefigaro.fr/rss/figaro_flash-actu.xml', 0, 0),
|
92 |
+
(74, 'https://www.lefigaro.fr/rss/figaro_sport.xml', 0, 0),
|
93 |
+
(75, 'https://www.rtl.fr/sitemap-news.xml', 0, 0),
|
94 |
+
(76, 'https://www.tf1info.fr/sitemap-n.xml', 0, 0),
|
95 |
+
(77, 'https://www.latribune.fr/feed.xml', 0, 0),
|
96 |
+
(78, 'https://www.la-croix.com/RSS/UNIVERS', 0, 0),
|
97 |
+
(79, 'https://www.la-croix.com/RSS/UNIVERS_WFRA', 0, 0),
|
98 |
+
(80, 'https://www.la-croix.com/RSS/WMON-EUR', 0, 0),
|
99 |
+
(81, 'https://www.la-croix.com/RSS/WECO-MON', 0, 0),
|
100 |
+
(82, 'https://www.nicematin.com/googlenews.xml', 0, 0),
|
101 |
+
(83, 'https://www.ouest-france.fr/rss/une', 0, 0),
|
102 |
+
(84, 'https://www.midilibre.fr/rss.xml', 0, 0),
|
103 |
+
(85, 'https://www.developpez.com/index/rss', 0, 0),
|
104 |
+
(86, 'https://www.laprovence.com/googlenews.xml', 0, 0),
|
105 |
+
(87, 'https://www.sudouest.fr/rss.xml', 0, 0),
|
106 |
+
(88, 'https://www.sudouest.fr/culture/cinema/rss.xml', 0, 0),
|
107 |
+
(89, 'https://www.sudouest.fr/economie/rss.xml', 0, 0),
|
108 |
+
(90, 'https://www.sudouest.fr/faits-divers/rss.xml', 0, 0),
|
109 |
+
(91, 'https://www.sudouest.fr/politique/rss.xml', 0, 0),
|
110 |
+
(92, 'https://www.sudouest.fr/sport/rss.xml', 0, 0),
|
111 |
+
(93, 'https://feeds.leparisien.fr/leparisien/rss', 0, 0),
|
112 |
+
(94, 'https://www.lepoint.fr/rss.xml', 0, 0),
|
113 |
+
(95, 'https://www.lepoint.fr/politique/rss.xml', 0, 0),
|
114 |
+
(96, 'https://www.lepoint.fr/monde/rss.xml', 0, 0),
|
115 |
+
(97, 'https://www.lepoint.fr/societe/rss.xml', 0, 0),
|
116 |
+
(98, 'https://www.lepoint.fr/economie/rss.xml', 0, 0),
|
117 |
+
(99, 'https://www.lepoint.fr/medias/rss.xml', 0, 0),
|
118 |
+
(100, 'https://www.lepoint.fr/science/rss.xml', 0, 0),
|
119 |
+
(101, 'https://www.lepoint.fr/sport/rss.xml', 0, 0),
|
120 |
+
(102, 'https://www.lepoint.fr/high-tech-internet/rss.xml', 0, 0),
|
121 |
+
(103, 'https://www.lepoint.fr/culture/rss.xml', 0, 0),
|
122 |
+
(104, 'https://www.nouvelobs.com/sport/rss.xml', 0, 0),
|
123 |
+
(105, 'https://www.nouvelobs.com/societe/rss.xml', 0, 0),
|
124 |
+
(106, 'https://www.nouvelobs.com/politique/rss.xml', 0, 0),
|
125 |
+
(107, 'https://www.nouvelobs.com/justice/rss.xml', 0, 0),
|
126 |
+
(108, 'https://www.nouvelobs.com/faits-divers/rss.xml', 0, 0),
|
127 |
+
(109, 'https://www.nouvelobs.com/economie/rss.xml', 0, 0),
|
128 |
+
(110, 'https://www.nouvelobs.com/culture/rss.xml', 0, 0),
|
129 |
+
(111, 'https://www.nouvelobs.com/monde/rss.xml', 0, 0),
|
130 |
+
(112, 'https://www.football365.fr/feed', 0, 0),
|
131 |
+
(113, 'https://www.europe1.fr/rss.xml', 0, 0),
|
132 |
+
(114, 'https://www.europe1.fr/rss/sport.xml', 0, 0),
|
133 |
+
(115, 'https://www.europe1.fr/rss/politique.xml', 0, 0),
|
134 |
+
(116, 'https://www.europe1.fr/rss/international.xml', 0, 0),
|
135 |
+
(117, 'https://www.europe1.fr/rss/technologies.xml', 0, 0),
|
136 |
+
(118, 'https://www.europe1.fr/rss/faits-divers.xml', 0, 0),
|
137 |
+
(119, 'https://www.europe1.fr/rss/economie.xml', 0, 0),
|
138 |
+
(120, 'https://www.europe1.fr/rss/culture.xml', 0, 0),
|
139 |
+
(121, 'https://www.europe1.fr/rss/societe.xml', 0, 0),
|
140 |
+
(122, 'https://www.europe1.fr/rss/sciences.xml', 0, 0),
|
141 |
+
(123, 'https://www.europe1.fr/rss/insolite.xml', 0, 0),
|
142 |
+
(124, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/belgique/?outputType=xml', 0, 0),
|
143 |
+
(125, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/economie/?outputType=xml', 0, 0),
|
144 |
+
(126, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/international/?outputType=xml', 0, 0),
|
145 |
+
(127, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/culture/?outputType=xml', 0, 0),
|
146 |
+
(128, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/sports/?outputType=xml', 0, 0),
|
147 |
+
(129, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/regions/?outputType=xml', 0, 0),
|
148 |
+
(130, 'https://www.courrierinternational.com/feed/all/rss.xml', 0, 0),
|
149 |
+
(131, 'https://www.20minutes.fr/feeds/rss-une.xml', 0, 0),
|
150 |
+
(132, 'https://www.huffingtonpost.fr/rss/all_headline.xml', 0, 0),
|
151 |
+
(133, 'https://fr.euronews.com/sitemaps/fr/latest-news.xml', 0, 0),
|
152 |
+
(134, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/belgique/?outputType=xml', 0, 0),
|
153 |
+
(135, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/faits/?outputType=xml', 0, 0),
|
154 |
+
(136, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/societe/?outputType=xml', 0, 0),
|
155 |
+
(137, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/monde/?outputType=xml', 0, 0),
|
156 |
+
(138, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/economie/?outputType=xml', 0, 0),
|
157 |
+
(139, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/sports/?outputType=xml', 0, 0),
|
158 |
+
(140, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/regions/?outputType=xml', 0, 0),
|
159 |
+
(141, 'https://www.rtbf.be/site-map/articles.xml', 0, 0),
|
160 |
+
(142, 'https://www.lematin.ch/sitemaps/fr/news.xml', 0, 0),
|
161 |
+
(143, 'https://www.24heures.ch/sitemaps/news.xml', 0, 0),
|
162 |
+
(144, 'https://www.20min.ch/sitemaps/fr/news.xml', 0, 0),
|
163 |
+
(145, 'https://www.tdg.ch/sitemaps/news.xml', 0, 0),
|
164 |
+
(146, 'https://www.lequipe.fr/sitemap/sitemap_google_news_gratuit.xml', 0, 0),
|
165 |
+
(147, 'http://feeds.feedburner.com/SoFoot', 0, 0),
|
166 |
+
(148, 'https://rmcsport.bfmtv.com/rss/football/', 0, 0),
|
167 |
+
(149, 'https://rmcsport.bfmtv.com/rss/rugby/', 0, 0),
|
168 |
+
(150, 'https://rmcsport.bfmtv.com/rss/basket/', 0, 0),
|
169 |
+
(151, 'https://rmcsport.bfmtv.com/rss/tennis/', 0, 0),
|
170 |
+
(152, 'https://rmcsport.bfmtv.com/rss/cyclisme/', 0, 0),
|
171 |
+
(153, 'https://rmcsport.bfmtv.com/rss/auto-moto/f1/', 0, 0),
|
172 |
+
(154, 'https://rmcsport.bfmtv.com/rss/handball/', 0, 0),
|
173 |
+
(155, 'https://rmcsport.bfmtv.com/rss/jeux-olympiques/', 0, 0),
|
174 |
+
(156, 'https://rmcsport.bfmtv.com/rss/football/ligue-1/', 0, 0),
|
175 |
+
(157, 'https://rmcsport.bfmtv.com/rss/sports-de-combat/', 0, 0),
|
176 |
+
(158, 'https://www.francebleu.fr/rss/a-la-une.xml', 0, 0),
|
177 |
+
(159, 'https://www.journaldunet.com/rss/', 0, 0),
|
178 |
+
(160, 'https://www.lindependant.fr/rss.xml', 0, 0),
|
179 |
+
(161, 'https://www.lopinion.fr/index.rss', 0, 0),
|
180 |
+
(162, 'https://www.marianne.net/rss.xml', 0, 0),
|
181 |
+
(163, 'https://www.01net.com/actualites/feed/', 0, 0),
|
182 |
+
(164, 'https://www.lamontagne.fr/sitemap.xml', 0, 0),
|
183 |
+
(165, 'https://www.science-et-vie.com/feed', 0, 0),
|
184 |
+
(166, 'https://fr.motorsport.com/rss/all/news/', 0, 0),
|
185 |
+
(167, 'https://www.presse-citron.net/feed/', 0, 0),
|
186 |
+
(168, 'https://www.valeursactuelles.com/feed?post_type=post&taxonomy_name=cult', 0, 0),
|
187 |
+
(169, 'https://www.valeursactuelles.com/feed?post_type=post&taxonomy_name=faits-di', 0, 0),
|
188 |
+
(170, 'https://www.larepubliquedespyrenees.fr/actualite/rss.xml', 0, 0),
|
189 |
+
(171, 'https://actu17.fr/feed', 0, 0),
|
190 |
+
(172, 'https://www.futura-sciences.com/rss/actualites.xml', 0, 0),
|
191 |
+
(173, 'https://trashtalk.co/feed', 0, 0),
|
192 |
+
(174, 'https://www.allocine.fr/rss/news.xml', 0, 0),
|
193 |
+
(175, 'https://www.jeuxvideo.com/rss/rss.xml', 0, 0),
|
194 |
+
(176, 'https://www.clubic.com/feed/news.rss', 0, 0),
|
195 |
+
(177, 'https://www.letelegramme.fr/rss.xml', 0, 0),
|
196 |
+
(178, 'https://www.sciencesetavenir.fr/rss.xml', 0, 0),
|
197 |
+
(179, 'https://www.onzemondial.com/rss/index.html', 0, 0),
|
198 |
+
(180, 'https://www.petitbleu.fr/rss.xml', 0, 0),
|
199 |
+
(181, 'https://www.centrepresseaveyron.fr/rss.xml', 0, 0),
|
200 |
+
(182, 'https://www.toulouscope.fr/rss.xml', 0, 0),
|
201 |
+
(183, 'https://cdn-elle.ladmedia.fr/var/plain_site/storage/flux_rss/fluxToutELLEfr.xml', 0, 0),
|
202 |
+
(184, 'https://www.santemagazine.fr/feeds/rss', 0, 0),
|
203 |
+
(185, 'https://www.santemagazine.fr/feeds/rss/actualites', 0, 0),
|
204 |
+
(186, 'https://www.nextinpact.com/rss/nobrief-noih.xml', 0, 0),
|
205 |
+
(187, 'https://services.lesechos.fr/rss/les-echos-entreprises.xml', 0, 0),
|
206 |
+
(188, 'https://services.lesechos.fr/rss/les-echos-finance-marches.xml', 0, 0),
|
207 |
+
(189, 'https://actu.fr/rss.xml', 0, 0),
|
208 |
+
(190, 'https://www.rugbyrama.fr/rss.xml', 0, 0),
|
209 |
+
(191, 'https://www.ladepeche.fr/rss.xml', 0, 0),
|
210 |
+
(192, 'https://services.lesechos.fr/rss/les-echos-economie.xml', 0, 0),
|
211 |
+
(193, 'https://radiofrance.fr/franceculture/rss', 0, 0),
|
212 |
+
(194, 'https://www.tomsguide.fr/feed/', 0, 0),
|
213 |
+
(195, 'https://air-cosmos.com/rss', 0, 0),
|
214 |
+
(196, 'https://www.rts.ch/info/toute-info/?format=rss/news', 0, 0),
|
215 |
+
(197, 'https://radiofrance.fr/franceinter/rss', 0, 0),
|
216 |
+
(198, 'https://atlantico.fr/rss', 0, 0),
|
217 |
+
(199, 'https://www.lejournaldesentreprises.com/rss-all', 0, 0),
|
218 |
+
(200, 'https://actualitte.com/rss-main.rss', 0, 0),
|
219 |
+
(201, 'https://www.lejournaldesarts.fr/rss.xml', 0, 0),
|
220 |
+
(202, 'https://www.rfi.fr/fr/rss', 0, 0),
|
221 |
+
(203, 'https://www.premiere.fr/rss/actu-live', 0, 0),
|
222 |
+
(204, 'https://ici.radio-canada.ca/rss/4159', 0, 0),
|
223 |
+
(205, 'https://korben.info/feed', 0, 0),
|
224 |
+
(206, 'http://feeds.feedburner.com/GeekzoneNews', 0, 0),
|
225 |
+
(207, 'https://cryptoast.fr/feed/', 0, 0),
|
226 |
+
(208, 'https://www.rue89strasbourg.com/feed', 0, 0),
|
227 |
+
(209, 'https://www.rue89lyon.fr/feed/', 0, 0),
|
228 |
+
(210, 'https://rue89bordeaux.com/feed/', 0, 0),
|
229 |
+
(211, 'https://www.journaldugeek.com/feed/', 0, 0),
|
230 |
+
(212, 'https://www.commentcamarche.net/rss/', 0, 0),
|
231 |
+
(213, 'https://unpointculture.com/feed/', 0, 0),
|
232 |
+
(214, 'https://www.usinenouvelle.com/rss/', 0, 0),
|
233 |
+
(215, 'https://rmccrime.bfmtv.com/rss/fil-info/', 0, 0),
|
234 |
+
(216, 'https://www.businessnews.com.tn/rss.xml', 0, 0),
|
235 |
+
(217, 'https://www.surf-finance.com/feed', 0, 0),
|
236 |
+
(218, 'https://services.lesechos.fr/rss/investir-actualites-valeurs.xml', 0, 0),
|
237 |
+
(219, 'https://services.lesechos.fr/rss/investir-conseils-boursiers.xml', 0, 0),
|
238 |
+
(220, 'https://www.inserm.fr/actualite/feed/', 0, 0),
|
239 |
+
(221, 'https://fr.cointelegraph.com/rss', 0, 0),
|
240 |
+
(222, 'https://infos.rtl.lu/rss/headlines', 0, 0);
|
241 |
+
COMMIT;
|
242 |
+
|
243 |
+
--
|
244 |
+
-- Structure of the `base_news` table
|
245 |
+
--
|
246 |
+
|
247 |
+
CREATE TABLE IF NOT EXISTS `base_news` (
|
248 |
+
`id` int NOT NULL AUTO_INCREMENT,
|
249 |
+
`key_media` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
250 |
+
`key_title` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
251 |
+
`media` int NOT NULL,
|
252 |
+
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
253 |
+
`link` tinyint NOT NULL,
|
254 |
+
`step` tinyint NOT NULL,
|
255 |
+
PRIMARY KEY (`id`),
|
256 |
+
KEY `url` (`url`(250)),
|
257 |
+
KEY `traitement` (`step`),
|
258 |
+
KEY `key_title` (`key_title`),
|
259 |
+
KEY `key_media` (`key_media`),
|
260 |
+
KEY `media` (`media`)
|
261 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
262 |
+
COMMIT;
|
extract_news/old/1_extract_rss.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* RSS Article URL Extractor
|
5 |
+
*
|
6 |
+
* This script is designed to fetch and extract article URLs from the RSS feeds of various French media outlets.
|
7 |
+
* The sources of these RSS feeds are stored in the `base_media` table of the database.
|
8 |
+
* For each source, the script retrieves the RSS content, processes each entry, and stores the article URLs
|
9 |
+
* into the database for further processing or analysis.
|
10 |
+
*
|
11 |
+
* @author Guillaume Eckendoerffer
|
12 |
+
* @date 07-09-2023
|
13 |
+
*/
|
14 |
+
|
15 |
+
|
16 |
+
// Include the database functions
|
17 |
+
include( "functions_mysqli.php" );
|
18 |
+
|
19 |
+
// Initialize global variables
|
20 |
+
$last = date("U");
|
21 |
+
$path = $_SERVER['DOCUMENT_ROOT'];
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Fetches the latest URL from the database.
|
25 |
+
*
|
26 |
+
* @param mysqli $mysqli The mysqli connection object.
|
27 |
+
* @return array Associative array containing the ID, URL, and the last update time.
|
28 |
+
*/
|
29 |
+
function fetchLatestURL( $mysqli ) {
|
30 |
+
$result = mysqli_query( $mysqli, "SELECT `id`, `url`, `last` FROM `base_media` ORDER By `last` ASC LIMIT 1" );
|
31 |
+
return mysqli_fetch_assoc( $result );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Updates the last fetched timestamp for the given source.
|
36 |
+
*
|
37 |
+
* @param mysqli $mysqli The mysqli connection object.
|
38 |
+
* @param int $id_source The ID of the source to update.
|
39 |
+
* @param int $last The new timestamp.
|
40 |
+
*/
|
41 |
+
function updateLastFetched( $mysqli, $id_source, $last ) {
|
42 |
+
mysqli_query( $mysqli, "UPDATE `base_media` SET `last`='$last' WHERE `id`='$id_source' LIMIT 1" );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Fetches the content from a given URL.
|
47 |
+
*
|
48 |
+
* @param string $url The URL to fetch.
|
49 |
+
* @return string The content of the fetched URL.
|
50 |
+
*/
|
51 |
+
function fetchURLContent( $url) {
|
52 |
+
$data = file_get_contents( trim( $url ) );
|
53 |
+
return $data;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Saves the given content to a file.
|
58 |
+
*
|
59 |
+
* @param string $path The path where the content should be saved.
|
60 |
+
* @param string $data The content to save.
|
61 |
+
*/
|
62 |
+
function saveToFile( $path, $data ) {
|
63 |
+
$file = fopen( $path, "w" );
|
64 |
+
fwrite( $file, $data );
|
65 |
+
fclose( $file );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Processes the fetched RSS content and updates the database accordingly.
|
70 |
+
*
|
71 |
+
* @param mysqli $mysqli The mysqli connection object.
|
72 |
+
* @param string $content The RSS content.
|
73 |
+
* @param int $id_source The ID of the source.
|
74 |
+
*/
|
75 |
+
function processRSSContent( $mysqli, $content, $id_source ) {
|
76 |
+
$a = new SimpleXMLElement( $content );
|
77 |
+
$nb = 0;
|
78 |
+
|
79 |
+
// First attempt: Process each item in the channel
|
80 |
+
foreach ( $a->channel->item as $entry ) {
|
81 |
+
$media = $entry->children( 'media', TRUE );
|
82 |
+
$attributes = $media->content->attributes();
|
83 |
+
$src = $attributes['url'];
|
84 |
+
$url = trim( $entry->link );
|
85 |
+
$url = str_replace(strstr( $url, "#"), "", $url );
|
86 |
+
$url = str_replace(strstr( $url, "?utm"), "", $url );
|
87 |
+
$url = str_replace(strstr( $url, "?xtor"), "", $url );
|
88 |
+
$key = md5( $url );
|
89 |
+
|
90 |
+
$txt = addslashes( strip_tags( html_entity_decode( $entry->description ) ) );
|
91 |
+
$title = addslashes( strip_tags( html_entity_decode( $entry->title ) ) );
|
92 |
+
$nb++;
|
93 |
+
|
94 |
+
$nb_base = mysqli_return_number( $mysqli, "SELECT `id` FROM `base_news` WHERE `key_media`='$key' OR `url` LIKE '$url%' LIMIT 1" );
|
95 |
+
|
96 |
+
if ( trim( $url ) != '' && trim( $title ) != '' && $nb_base == 0 ) {
|
97 |
+
mysqli_query( $mysqli, "INSERT INTO `base_news` (`id`, `key_media`, `media`, `url`, `link`, `step`) VALUES (NULL, '$key', '$id_source', '$url', '0', '0');" );
|
98 |
+
$id_inserted = $mysqli->insert_id;
|
99 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `title`='$title' WHERE `id`='$id_inserted' LIMIT 1" );
|
100 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `txt_clean`='$txt' WHERE `id`='$id_inserted' LIMIT 1" );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
// Second attempt: If no entries were processed in the first attempt, process the top-level entries
|
105 |
+
if ( !$nb ) {
|
106 |
+
foreach ( $a as $entry ) {
|
107 |
+
$url = $entry->loc;
|
108 |
+
$url = str_replace( strstr( $url, "#" ), "", $url );
|
109 |
+
$url = str_replace(strstr( $url, "?utm"), "", $url );
|
110 |
+
$key = md5( $url );
|
111 |
+
$nb++;
|
112 |
+
$nb_base = mysqli_return_number( $mysqli, "SELECT `id` FROM `base_news` WHERE `key_media`='$key' OR `url` LIKE '$url%' LIMIT 1" );
|
113 |
+
|
114 |
+
if ( trim( $url ) != '' && $nb_base == 0 ) {
|
115 |
+
mysqli_query( $mysqli, "INSERT INTO `base_news` (`id`, `key_media`, `media`, `url`, `link`, `step`) VALUES (NULL, '$key', '$id_source', '$url', '0', '0');" );
|
116 |
+
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$nb_base_news = mysqli_return_number( $mysqli, "SELECT `id` FROM `base_news` WHERE `media` = '$id_source'" );
|
122 |
+
mysqli_query( $mysqli, "UPDATE `base_media` SET `nb`='$nb_base_news' WHERE `id`='$id_source' LIMIT 1" );
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
// Main script execution
|
127 |
+
$record = fetchLatestURL( $mysqli );
|
128 |
+
$id_source = $record['id'];
|
129 |
+
$url = trim( $record['url'] );
|
130 |
+
$last_update = $record['last'];
|
131 |
+
|
132 |
+
echo "$id_source # $url";
|
133 |
+
|
134 |
+
// Exit if the last update is too recent < 1h
|
135 |
+
if ( $last_update + 3600 > $last ) {
|
136 |
+
exit;
|
137 |
+
}
|
138 |
+
|
139 |
+
updateLastFetched( $mysqli, $id_source, $last );
|
140 |
+
$data = fetchURLContent( $url );
|
141 |
+
if( trim( $data )!='' ){
|
142 |
+
saveToFile( $path . "/sources/rss/" . $id_source . ".txt", $data );
|
143 |
+
processRSSContent( $mysqli, $data, $id_source );
|
144 |
+
}
|
145 |
+
|
146 |
+
echo "<script type=\"text/javascript\">location.href='" . $_SERVER ['REQUEST_URI'] . "';</script>";
|
147 |
+
|
148 |
+
?>
|
149 |
+
|
extract_news/old/2_extract_news.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* News Article Source Fetcher
|
5 |
+
*
|
6 |
+
* This script is designed to extract the content of news articles from various French media sources.
|
7 |
+
* The URLs of these articles are retrieved from the `base_news` table, where articles marked with
|
8 |
+
* a `step` value of '0' are pending extraction.
|
9 |
+
*
|
10 |
+
* Once extracted, the content of each article is saved locally for further processing. This separation
|
11 |
+
* of content fetching and processing is intentional to optimize resource management.
|
12 |
+
*
|
13 |
+
* The script operates in batches, processing a defined number of entries (`NB_BY_STEP`) at a time.
|
14 |
+
* After extraction, the `step` value of the processed articles is updated to '1' to indicate completion.
|
15 |
+
*
|
16 |
+
* For performance monitoring, the script outputs the processed article IDs, URLs, and calculates the average
|
17 |
+
* processing time per article.
|
18 |
+
*
|
19 |
+
* @author Guillaume Eckendoerffer
|
20 |
+
* @date 07-09-2023
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
// Include the database functions
|
25 |
+
include( "functions_mysqli.php" );
|
26 |
+
|
27 |
+
// Initialize global variables
|
28 |
+
const NB_BY_STEP = 20; // nb per steep
|
29 |
+
$last = date( "U" );
|
30 |
+
$path = $_SERVER['DOCUMENT_ROOT'];
|
31 |
+
|
32 |
+
// Capture the start time for performance monitoring
|
33 |
+
$time_start = microtime( true );
|
34 |
+
|
35 |
+
// Fetch a batch of unprocessed news entries
|
36 |
+
$return ='';
|
37 |
+
$result = mysqli_query( $mysqli, "SELECT `id`, `url` FROM `base_news` WHERE `step`='0' ORDER BY RAND() LIMIT " . NB_BY_STEP );
|
38 |
+
while ( $row = mysqli_fetch_assoc( $result ) ) {
|
39 |
+
|
40 |
+
$id_source = $row["id"];
|
41 |
+
$url = trim( $row["url"] );
|
42 |
+
$time_start_item = microtime( true );
|
43 |
+
|
44 |
+
// Mark the news entry as being processed
|
45 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `step`='1' WHERE `id`='$id_source' LIMIT 1" );
|
46 |
+
|
47 |
+
// Fetch the content of the news URL
|
48 |
+
$data = file_get_contents( trim( $url ) );
|
49 |
+
|
50 |
+
// Save the fetched data to a local file
|
51 |
+
$inF = fopen( "$path/sources/html_news/$id_source.txt", "w" );
|
52 |
+
fwrite( $inF, $data );
|
53 |
+
fclose( $inF );
|
54 |
+
$time_item = number_format( ( microtime( true ) - $time_start_item ) , 3, ',', '' ) . 's';
|
55 |
+
|
56 |
+
// Output the ID and URL for monitoring purposes
|
57 |
+
$return .= "($id_source) [$time_item] $url <br />";
|
58 |
+
}
|
59 |
+
|
60 |
+
// Fetch the count of news entries that haven't been processed
|
61 |
+
$nb_base = mysqli_return_number( $mysqli, "SELECT `id` FROM `base_news` WHERE `step`='0'" );
|
62 |
+
|
63 |
+
// Calculate and display the processing time
|
64 |
+
$time = number_format( ( ( microtime( true ) - $time_start ) / NB_BY_STEP ), 3, ',', '' ) .'s/item';
|
65 |
+
echo "<head><title>Rem: $nb_base - $time</title></head> $return";
|
66 |
+
|
67 |
+
// If no more entries are found, exit, else move to the next processing step
|
68 |
+
if ( !isset( $id_source ) ) exit;
|
69 |
+
|
70 |
+
echo "<script type=\"text/javascript\">location.href='" . $_SERVER ['REQUEST_URI'] . "';</script>";
|
71 |
+
|
72 |
+
?>
|
73 |
+
|
extract_news/old/3_extract_news_txt.php
ADDED
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* News Article Text Extractor
|
5 |
+
*
|
6 |
+
* This script extracts the text from locally-stored news articles. The main goal is
|
7 |
+
* to retrieve clean text with minimal external elements, such as user menus, article lists,
|
8 |
+
* and advertisements.
|
9 |
+
*
|
10 |
+
* To use this script, you must have electrolinux/phpquery installed. Install it using Composer with
|
11 |
+
* the command: composer require electrolinux/phpquery.
|
12 |
+
*
|
13 |
+
* After completing this step, you can use the Python script located at /dataset/2_cleaning_txt.py
|
14 |
+
* to standardize the text for your dataset.
|
15 |
+
*
|
16 |
+
* Debugging:
|
17 |
+
* - Enable debugging by setting the `$debug` variable to 1. This will display the hexadecimal
|
18 |
+
* code for each character in the final version before being saved in /txt_news/. Additionally,
|
19 |
+
* it will show the full HTML version or the complete HTML source if there's no output.
|
20 |
+
* - GET variables:
|
21 |
+
* - `?id=`: Use this integer value to display a specific news article. This corresponds
|
22 |
+
* to the ID in the `base_news` table.
|
23 |
+
* - `?media=`: Use this integer value to display a specific media. This corresponds
|
24 |
+
* to the ID in the `base_media` table.
|
25 |
+
*
|
26 |
+
* Note:
|
27 |
+
* RSS feed links for media sources, as well as the HTML structure of media pages, tend to change
|
28 |
+
* and evolve regularly. It's crucial to regularly check the output per media source and adjust
|
29 |
+
* the parsing process to ensure high-quality text extraction and to address potential changes
|
30 |
+
* in RSS feed URLs.
|
31 |
+
*
|
32 |
+
* @author Guillaume Eckendoerffer
|
33 |
+
* @date 08-09-2023
|
34 |
+
*/
|
35 |
+
|
36 |
+
|
37 |
+
$debug = 0;
|
38 |
+
$redirect_enabled = 1;
|
39 |
+
$time_start = microtime(true);
|
40 |
+
|
41 |
+
// composer require electrolinux/phpquery
|
42 |
+
require 'vendor/autoload.php';
|
43 |
+
|
44 |
+
// Include the database functions
|
45 |
+
include( "functions_mysqli.php" );
|
46 |
+
|
47 |
+
// Initialize global variables
|
48 |
+
$last = date( "U" );
|
49 |
+
$path = $_SERVER ['DOCUMENT_ROOT'];
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Cleans the input text by replacing specific characters and filtering out unwanted Unicode categories.
|
53 |
+
*
|
54 |
+
* @param string $text The original text to be cleaned.
|
55 |
+
* @return string The cleaned text with specific replacements and filtered characters.
|
56 |
+
*
|
57 |
+
* @example
|
58 |
+
* clean_text("Hello`World!"); // Returns "Hello'World!"
|
59 |
+
*/
|
60 |
+
function clean_text( $text ) {
|
61 |
+
$text = str_replace( chr( 8217 ), "'", $text );
|
62 |
+
$text = str_replace( "`", "'", $text );
|
63 |
+
$text = str_replace( "’", "'", $text );
|
64 |
+
$dict_char = str_split( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/*-+.$*ù^£–—“”—" .
|
65 |
+
"µ%¨!:;,?./§&é\"'(è_çàâ)=°ç[{#}]¤~²ôûîïäëêíáã•©®€¢¥ƒÁÂÀÅÃäÄæÇÉÊÈËÍîÎñÑÓÔóÒøØõÕö" .
|
66 |
+
"ÖœŒšŠßðÐþÞÚúûÛùÙüÜýÝÿŸαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ×÷" .
|
67 |
+
"±∓≠<>≤≥≈∝∞∫∑∈∉⊆⊇⊂⊃∪∩∧∨¬∀∃π×⨯⊗→←↑↓↔ ϒϖϑℵ⟩⟨⋅⊗⊄≅∗∉∅⇓⇑⇐↵ℜℑ℘⊕⊥∼∴∪∨∧∠∝" .
|
68 |
+
"∋∈∇∃∀⇔⇒∩¬∞√∑∏∂″′ªº³²¹¾½¼‰¶‡†¿§«»@" );
|
69 |
+
|
70 |
+
for ( $i = 0; $i < strlen( $text ); $i++ ) {
|
71 |
+
$char = $text[$i];
|
72 |
+
if ( !in_array( $char, $dict_char ) ) {
|
73 |
+
$text = str_replace( $char, ' ', $text );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return $text;
|
78 |
+
}
|
79 |
+
|
80 |
+
// Search for the source code of the next record to process
|
81 |
+
if( isset( $_GET["id"] ) AND is_numeric( $_GET["id"] ) ) $req="`id`='" . $_GET["id"] . "'"; else $req="`step`='1' ORDER By `id` ";
|
82 |
+
if( isset( $_GET["media"] ) AND is_numeric( $_GET["media"] ) ) $req="`media`='" . $_GET["media"] . "' ORDER By Rand() ";
|
83 |
+
$result = mysqli_query( $mysqli, "SELECT `id`, `url`, `title`, `txt_clean` FROM `base_news` WHERE $req LIMIT 1" );
|
84 |
+
while ( $row = mysqli_fetch_assoc( $result ) ) {
|
85 |
+
$id_source = $row["id"];
|
86 |
+
$next = $id_source + 1;
|
87 |
+
$url = trim( $row["url"] );
|
88 |
+
$title = trim( html_entity_decode( $row["title"] ) );
|
89 |
+
$txt_clean = trim( $row["txt_clean"] );
|
90 |
+
}
|
91 |
+
if( !isset( $id_source ) ) exit;
|
92 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `step`='2' WHERE `id`='$id_source' LIMIT 1" );
|
93 |
+
|
94 |
+
$htmlContent = '';
|
95 |
+
$file_path = "$path/sources/html_news/$id_source.txt";
|
96 |
+
if ( file_exists( $file_path ) ) $htmlContent = implode ( '', file ( $file_path ) );
|
97 |
+
if( substr_count( $url, '/replay' ) ) $htmlContent ='';
|
98 |
+
|
99 |
+
// utf8
|
100 |
+
$current_encoding = mb_detect_encoding( $htmlContent, 'auto' );
|
101 |
+
try {
|
102 |
+
$htmlContent = ($current_encoding == 'UTF-8') ? $htmlContent : mb_convert_encoding($htmlContent, 'UTF-8', $current_encoding);
|
103 |
+
} catch (ValueError $e) {
|
104 |
+
if( $redirect_enabled )
|
105 |
+
echo "<script type=\"text/javascript\">location.href='" . str_replace( strstr( $_SERVER ['REQUEST_URI'], '?' ), "", $_SERVER ['REQUEST_URI'] ) . "?id=$next';</script>";
|
106 |
+
else
|
107 |
+
echo "Error: mb_convert_encoding()";
|
108 |
+
exit;
|
109 |
+
}
|
110 |
+
|
111 |
+
$doc = \phpQuery::newDocument( $htmlContent );
|
112 |
+
|
113 |
+
// Extracting the title
|
114 |
+
if( trim( $title )=='' ){
|
115 |
+
$title = html_entity_decode( trim( pq('h1')->text() ) );
|
116 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `title`='" . addslashes( $title ) . "' WHERE `id`='$id_source' LIMIT 1" );
|
117 |
+
}
|
118 |
+
|
119 |
+
// Extracting the description
|
120 |
+
if( trim( $txt_clean )=='' ){
|
121 |
+
$description = pq('meta[name="description"]')->attr('content');
|
122 |
+
if( trim( $description )=='' ){
|
123 |
+
|
124 |
+
$description = pq('meta[name="og:description"]')->attr('content');
|
125 |
+
}
|
126 |
+
if( trim( $description )!='' ){
|
127 |
+
|
128 |
+
$txt_clean = html_entity_decode( trim( $description ) );
|
129 |
+
$txt_clean = preg_replace( '/\s{2,}/', ' ', $txt_clean );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
// Extracting the text from source code
|
134 |
+
$content ='';
|
135 |
+
$html ='';
|
136 |
+
// Extracting the text from <article> tag
|
137 |
+
$color ='#008000';
|
138 |
+
if( !substr_count( $url, ".rtbf.be" ) ) {
|
139 |
+
foreach ( pq( 'article p' ) as $p ) {
|
140 |
+
|
141 |
+
$html .= " " . trim( pq( $p )->html() ) . " ";
|
142 |
+
if( substr_count( $url, ".futura-sciences.com" ) ) pq($p)->find('a')->remove();
|
143 |
+
$content .= " " . trim( html_entity_decode( pq( $p )->text() ) ) . " ";
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
// Extracting from <p> tags after <h1>
|
148 |
+
if( trim( $content )=='' ){
|
149 |
+
$start = pq('h1:first');
|
150 |
+
$nextElements = pq($start)->nextAll();
|
151 |
+
foreach ($nextElements as $element) {
|
152 |
+
if (pq($element)->is('p')) {
|
153 |
+
$start = trim(html_entity_decode(pq($element)->text()));
|
154 |
+
}
|
155 |
+
}
|
156 |
+
foreach ( pq( 'p' ) as $p ) {
|
157 |
+
$content .= " " . trim( html_entity_decode( pq( $p )->text() ) ) . " ";
|
158 |
+
}
|
159 |
+
if( trim( $start )!='' ) $content = strstr( $content, $start );
|
160 |
+
|
161 |
+
$color ='#000080';
|
162 |
+
}
|
163 |
+
|
164 |
+
// Extracting from <p> tags
|
165 |
+
if( trim( $content )=='' ){
|
166 |
+
|
167 |
+
foreach ( pq( 'p' ) as $p ) {
|
168 |
+
$content .= " " . trim( html_entity_decode( pq( $p )->text() ) ) ;
|
169 |
+
}
|
170 |
+
$color ='#888';
|
171 |
+
}
|
172 |
+
|
173 |
+
// Adding a space after punctuation and various deletions
|
174 |
+
$content = str_replace(array("\r", "\n"), ' ', $content);
|
175 |
+
$remove = [
|
176 |
+
'?',
|
177 |
+
'!',
|
178 |
+
";",
|
179 |
+
"!",
|
180 |
+
"»",
|
181 |
+
"]",];
|
182 |
+
foreach ( $remove as $phrase ) {
|
183 |
+
$content = str_replace( $phrase, $phrase . ' ', $content );
|
184 |
+
}
|
185 |
+
$content = str_replace( html_entity_decode(' '), " ", $content ); // Standardizing spaces
|
186 |
+
$content = preg_replace( '/\s{2,}/', ' ', $content ); // one space, no more
|
187 |
+
$pattern = '/À lire aussi.{1,200}?»/';
|
188 |
+
$content = preg_replace($pattern, ' ', $content);
|
189 |
+
$pattern = '/Temps de Lecture.{1,20}? Fiche/';
|
190 |
+
$content = preg_replace($pattern, ' ', $content);
|
191 |
+
$pattern = '/Temps de Lecture.{1,20}? min./';
|
192 |
+
$content = preg_replace($pattern, ' ', $content);
|
193 |
+
|
194 |
+
// Media-specific cutting rules
|
195 |
+
if( substr_count( $url, ".elle.fr" ) ){
|
196 |
+
$pattern = '/Note :.{13,45}? sur 5/';
|
197 |
+
$content = preg_replace($pattern, ' ', $content);
|
198 |
+
$content = str_replace( strstr( $content, " sur 5 " ), '', $content );
|
199 |
+
}
|
200 |
+
|
201 |
+
if( substr_count( $url, ".latribune.fr" ) ){
|
202 |
+
$content = str_replace( "Partager :", ' ', $content );
|
203 |
+
}
|
204 |
+
|
205 |
+
if( substr_count( $url, ".techno-science.net" ) ){
|
206 |
+
$content = strip_tags( strstr( $htmlContent, "suivez-nous sur" ) );
|
207 |
+
$content = strstr( $content, ');' );
|
208 |
+
$content = html_entity_decode( str_replace( strstr( $content, "Référence" ), "", $content ) );
|
209 |
+
}
|
210 |
+
|
211 |
+
if( substr_count( $url, ".lexpress.fr" ) ){
|
212 |
+
$content = strstr( $htmlContent, "article__text" ) ;
|
213 |
+
$content = strstr( $content, ">" );
|
214 |
+
$content = substr( $content,1,99999 );
|
215 |
+
$content = html_entity_decode( strip_tags( str_replace( strstr( $content, "<div id=\"taboola" ), "", $content ) ) );
|
216 |
+
}
|
217 |
+
|
218 |
+
$content_or = $content; // Store the original content
|
219 |
+
|
220 |
+
// List of starting phrases to find and use as the new starting point
|
221 |
+
$startPhrases = [
|
222 |
+
"Partager l'article sur Twitter",
|
223 |
+
" au sommaire ",
|
224 |
+
"TF1 INFO",
|
225 |
+
"Licence Creative Commons",
|
226 |
+
" / AFP ",
|
227 |
+
"ne rien louper de vos programmes favoris.",
|
228 |
+
"© Belga"
|
229 |
+
];
|
230 |
+
|
231 |
+
foreach ( $startPhrases as $phrase ) {
|
232 |
+
if ( strpos( $content, $phrase ) !== false ) {
|
233 |
+
$content = strstr( $content, $phrase );
|
234 |
+
$content = str_replace( $phrase, ' ', $content );
|
235 |
+
break;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
// List of phrases to remove from the end of content
|
240 |
+
$removePhrasesEnd = [
|
241 |
+
'Sur le même sujet',
|
242 |
+
'Sur lemême thème',
|
243 |
+
'Nos articles à lire aussi',
|
244 |
+
'Suivez toute l’actualité de vos villes',
|
245 |
+
'En direct',
|
246 |
+
"J'ai déjà un compte",
|
247 |
+
'> Ecoutez',
|
248 |
+
'Courrier international',
|
249 |
+
'Vous avez trouvé une erreur?',
|
250 |
+
'Il vous reste',
|
251 |
+
'Partager',
|
252 |
+
"Suivez-nous",
|
253 |
+
'Newsletter',
|
254 |
+
'Abonnez-vous',
|
255 |
+
'1€ le premier mois',
|
256 |
+
'Votre France Bleu',
|
257 |
+
'Soyez le premier à commenter cet article',
|
258 |
+
'Pour rester informé(e)',
|
259 |
+
'Un site du groupe',
|
260 |
+
"Cet article est réservé aux abonnés",
|
261 |
+
"Recevez chaque vendredi l'essentiel",
|
262 |
+
"Suivez toute l'actualité de ZDNet",
|
263 |
+
"Suivez-nous sur les résaux sociaux",
|
264 |
+
". par ",
|
265 |
+
"Le résumé de la semaine",
|
266 |
+
"ACTUELLEMENT EN KIOSQUE",
|
267 |
+
" L’actualité par la rédaction de",
|
268 |
+
"Gratis onbeperkt",
|
269 |
+
"Débloquez immédiatement cet article",
|
270 |
+
"À voir également",
|
271 |
+
"null null null ",
|
272 |
+
'Du lundi au vendredi, à 19h',
|
273 |
+
"La rédaction de La Tribune",
|
274 |
+
"Restez toujours informé: suivez-nous sur Google Actualités",
|
275 |
+
"Du lundi au vendredi, votre rendez-vous",
|
276 |
+
"Enregistrer mon nom, mon e-mail",
|
277 |
+
"Mot de passe oublié",
|
278 |
+
'(function',
|
279 |
+
];
|
280 |
+
|
281 |
+
foreach ( $removePhrasesEnd as $phrase ) {
|
282 |
+
$content = str_replace( strstr( $content, $phrase ), "", $content);
|
283 |
+
}
|
284 |
+
|
285 |
+
// List of phrases to remove
|
286 |
+
$removePhrases = [
|
287 |
+
"Inscrivez-vous pour recevoir les newsletters de la Rép' dans votre boîte mail",
|
288 |
+
"TF1 INFO",
|
289 |
+
"Sujet TF1 Info",
|
290 |
+
"Sujet JT LCI",
|
291 |
+
"TF1 Info ",
|
292 |
+
"JT 20h WE ",
|
293 |
+
"JT 20h Semaine ",
|
294 |
+
"Source :",
|
295 |
+
"Inscrivez-vous aux newsletters de la RTBF Tous les sujets de l'article",
|
296 |
+
"Pour voir ce contenu, connectez-vous gratuitement",
|
297 |
+
">> LIRE AUSSI",
|
298 |
+
"À LIRE AUSSI",
|
299 |
+
"A lire aussi >> ",
|
300 |
+
" → À LIRE.",
|
301 |
+
"À voir également",
|
302 |
+
"Image d'illustration -",
|
303 |
+
"Le média de la vie locale ",
|
304 |
+
"Les plus lus.",
|
305 |
+
"Ce live est à présent terminé.",
|
306 |
+
" . -",
|
307 |
+
"[…]",
|
308 |
+
"[.]",
|
309 |
+
"(…)",
|
310 |
+
"(.)",
|
311 |
+
"©"
|
312 |
+
];
|
313 |
+
|
314 |
+
foreach ( $removePhrases as $phrase ) {
|
315 |
+
$content = str_replace( $phrase, ".", $content );
|
316 |
+
}
|
317 |
+
$content = preg_replace( '/\.{2,}/', '.', $content );
|
318 |
+
$content = preg_replace( '/\s{2,}/', ' ', $content );
|
319 |
+
$content = preg_replace( '/-{2,}/', '-', $content );
|
320 |
+
$content = preg_replace( '/__{2,}/', '_', $content );
|
321 |
+
|
322 |
+
// Display
|
323 |
+
echo "<span style='font-family: verdana;font-size: .9em;'>($id_source) [$current_encoding] $url <br /><br />" .
|
324 |
+
"<b>Title: $title</b> <br /><br />" .
|
325 |
+
"<span style='color:$color;'>Content: $content</span>";
|
326 |
+
|
327 |
+
if( strlen( $content ) != strlen( $content_or ) ){
|
328 |
+
echo "<hr> <span style='color:#ff0000;'>$content_or</span>"; // original content
|
329 |
+
}
|
330 |
+
|
331 |
+
// Formatting the output content for the txt file in the $add variable
|
332 |
+
$content = strip_tags($content);
|
333 |
+
$add = html_entity_decode( $title ) . '. ';
|
334 |
+
if( trim( $txt_clean ) != '' ) $add .= str_replace( "..", ".", html_entity_decode( $txt_clean ) . '. ' );
|
335 |
+
if( strlen( $content ) > 160 ) $add .= $content . '.';
|
336 |
+
$add = trim( clean_text( $add ) );
|
337 |
+
|
338 |
+
$remove = [ '. .', '..', "?.", "!.", ";.", "??", "? ?",];
|
339 |
+
foreach ( $remove as $phrase ) {
|
340 |
+
$add = str_replace( $phrase, substr( $phrase,0,1 ). ' ', $add );
|
341 |
+
}
|
342 |
+
$add = strip_tags( $add );
|
343 |
+
$add = str_replace( html_entity_decode( ' ' ), " ", $add );
|
344 |
+
$add = preg_replace( '/&#(x[0-9a-fA-F]+|\d+);/', ' ', $add );
|
345 |
+
$add = preg_replace( '/&#\d+;/', ' ', $add );
|
346 |
+
$add = preg_replace( '/[\x{1F534}\x{26A0}\x{1F3C9}\x{1F6A8}\x{1F6D2}\x{1FA82}\x{25B6}\x{2139}\x{2600}-\x{26FF}\x{1F300}-\x{1F5FF}\x{1F600}-\x{1F64F}\x{1F680}-\x{1F6FF}\x{1F700}-\x{1F77F}\x{1F780}-\x{1F7FF}\x{1F800}-\x{1F8FF}\x{1F900}-\x{1F9FF}\x{1FA00}-\x{1FA6F}\x{1FA70}-\x{1FAFF}]/u', ' ', $add );
|
347 |
+
$add = preg_replace( '/\s{2,}/', ' ', $add );
|
348 |
+
|
349 |
+
$replacements = array( "À" => "À", "Â" => "Â", "Ã" => "Ã", "Ä" => "Ä", "Â" => "Â", "Ã…" => "Å", "á" => "á", "â" => "â", "ã" => "ã", "ä" => "ä", "Ã¥" => "å", "Ã’" => "Ò", "Ó" => "Ó", "Ô" => "Ô", "Õ" => "Õ", "Ö" => "Ö", "Ø" => "Ø", "ò" => "ò", "ó" => "ó", "ô" => "ô", "õ" => "õ", "ö" => "ö", "ø" => "ø", "È" => "È", "É" => "É", "Ê" => "Ê", "Ë" => "Ë", "è" => "è", "é" => "é", "ê" => "ê", "ë" => "ë", "Ç" => "Ç", "ç" => "ç", "ÃŒ" => "Ì", "ÃŽ" => "Î", "ì" => "ì", "Ã" => "í", "î" => "î", "ï" => "ï", "Ù" => "Ù", "Ú" => "Ú", "Û" => "Û", "Ãœ" => "Ü", "ù" => "ù", "ú" => "ú", "û" => "û", "ü" => "ü", "ÿ" => "ÿ", "Ñ" => "Ñ", "ñ" => "ñ", "Ã" => "Á", "Ã" => "Í", "à " => "à", '’'=>'\'', "«" => "«", '»'=>'»');
|
350 |
+
$add = str_replace( array_keys( $replacements ), array_values( $replacements ), $add );
|
351 |
+
|
352 |
+
|
353 |
+
// Additional display for debugging and testing
|
354 |
+
if( $debug ){
|
355 |
+
if( trim( $content )=='' ) {
|
356 |
+
echo "<hr /> html:<br /> $html " . htmlentities( $html ) . "<hr />" .
|
357 |
+
htmlentities( $doc->text() ) .'<br />' .
|
358 |
+
'Source lenght: ' . strlen( $htmlContent );
|
359 |
+
}
|
360 |
+
$test_char ="";
|
361 |
+
foreach ( str_split( $add ) as $char) {
|
362 |
+
$test_char .= $char . "(" . bin2hex($char). ") ";
|
363 |
+
}
|
364 |
+
echo '<hr /> hexadecimal code for each character from $add var: <br />' . $test_char;
|
365 |
+
} else {
|
366 |
+
if( $id_source%10000 === 0 ) mysqli_query( $mysqli, "OPTIMIZE TABLE `base_news`;" );
|
367 |
+
}
|
368 |
+
|
369 |
+
// Saving the title + description + text in a text file
|
370 |
+
$key_title = md5( $title );
|
371 |
+
$nb_base = mysqli_return_number( $mysqli, "SELECT `id` FROM `base_news` WHERE `key_title`='$key_title' LIMIT 1" );
|
372 |
+
|
373 |
+
if( isset( $_GET["id"] ) OR isset( $_GET["media"] ) OR ( strlen( $content ) > 200 AND !$nb_base ) ){
|
374 |
+
mysqli_query( $mysqli, "UPDATE `base_news` SET `key_title` = '$key_title' WHERE `id`='$id_source' LIMIT 1" );
|
375 |
+
|
376 |
+
$bom = "\xEF\xBB\xBF";
|
377 |
+
file_put_contents( "$path/sources/txt_news/$id_source.txt", $bom . $add );
|
378 |
+
}
|
379 |
+
|
380 |
+
$execution_time = microtime(true) - $time_start;
|
381 |
+
echo"<hr /> execution time: $execution_time";
|
382 |
+
if( $id_source%100 === 0 ) sleep(1); // throttling navigation to prevent the browser from hanging.
|
383 |
+
if( $redirect_enabled ) echo "<script type=\"text/javascript\">location.href='" . str_replace( strstr( $_SERVER ['REQUEST_URI'], '?' ), "", $_SERVER ['REQUEST_URI'] ) . "?id=$next';</script>";
|
384 |
+
|
385 |
+
|
386 |
+
?>
|
extract_news/old/4_extract_news_url.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* News Links Extractor
|
5 |
+
*
|
6 |
+
* Extracts and stores relevant links from local French online news articles.
|
7 |
+
*
|
8 |
+
* To use this script, you must have electrolinux/phpquery installed. Install it using Composer with
|
9 |
+
* the command: composer require electrolinux/phpquery.
|
10 |
+
*
|
11 |
+
* @author Guillaume Eckendoerffer
|
12 |
+
* @date 08-09-2023
|
13 |
+
*/
|
14 |
+
|
15 |
+
// composer require electrolinux/phpquery
|
16 |
+
require 'vendor/autoload.php';
|
17 |
+
|
18 |
+
// Include the database functions
|
19 |
+
include("functions_mysqli.php");
|
20 |
+
|
21 |
+
$path = $_SERVER ['DOCUMENT_ROOT'];
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Get the base domain path from a given URL
|
25 |
+
*
|
26 |
+
* @param string $url The input URL
|
27 |
+
* @return string|false The base domain path or false on failure
|
28 |
+
*/
|
29 |
+
function getDomPath( $url ) {
|
30 |
+
$parsedUrl = parse_url( $url );
|
31 |
+
if ( !$parsedUrl || !isset( $parsedUrl['scheme'] ) || !isset( $parsedUrl['host'] ) ) {
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
return "{$parsedUrl['scheme']}://{$parsedUrl['host']}";
|
35 |
+
}
|
36 |
+
|
37 |
+
// Query the database for a news source with no link
|
38 |
+
$result = mysqli_query( $mysqli, "SELECT `id`, `url`, `media` FROM `base_news` WHERE `link`='0' AND `step` > 0 ORDER BY Rand() LIMIT 1" );
|
39 |
+
$row = mysqli_fetch_assoc( $result );
|
40 |
+
if (!$row) {
|
41 |
+
exit('No unprocessed news source found.');
|
42 |
+
}
|
43 |
+
|
44 |
+
$id_source = $row["id"];
|
45 |
+
$url_source = trim( $row["url"] );
|
46 |
+
$id_media = $row["media"];
|
47 |
+
$last = date( "U" );
|
48 |
+
$dom = getDomPath( $url_source );
|
49 |
+
|
50 |
+
echo "<span style='font-family: verdana;font-size: .9em;'>$id_source) $url_source => $dom <br /><br />";
|
51 |
+
|
52 |
+
// Mark the source as processed
|
53 |
+
mysqli_query($mysqli, "UPDATE `base_news` SET `link`='1' WHERE `id`='$id_source' LIMIT 1");
|
54 |
+
|
55 |
+
// Load the source content
|
56 |
+
$htmlContent = '';
|
57 |
+
$file_path = "$path/sources/html_news/$id_source.txt";
|
58 |
+
if ( file_exists( $file_path ) ){
|
59 |
+
$htmlContent = implode( '', file( $file_path ) );
|
60 |
+
} else {
|
61 |
+
echo "<script type=\"text/javascript\">location.href='" . $_SERVER['REQUEST_URI'] . "';</script>";
|
62 |
+
}
|
63 |
+
|
64 |
+
$doc = \phpQuery::newDocument($htmlContent);
|
65 |
+
|
66 |
+
foreach ( $doc['a'] as $link ) {
|
67 |
+
$url = trim( pq( $link )->attr( 'href' ) );
|
68 |
+
$url = str_replace( strstr( $url, "#" ), "", $url );
|
69 |
+
$url = str_replace( strstr( $url, "?"), "", $url );
|
70 |
+
|
71 |
+
if ( !substr_count( $url, "//" ) ) {
|
72 |
+
$url = ( substr( $url, 0, 1 ) != '/' ) ? $dom . '/' . $url : $dom . $url;
|
73 |
+
} elseif( !substr_count( $url, "http" ) ){
|
74 |
+
$url = 'https:' . $url;
|
75 |
+
}
|
76 |
+
|
77 |
+
$key = md5( $url );
|
78 |
+
|
79 |
+
$nb_base_news = mysqli_return_number($mysqli, "SELECT `id` FROM `base_news` WHERE `url` LIKE '$url%' OR `key_media`='$key' LIMIT 1");
|
80 |
+
|
81 |
+
if (substr($url, 0, strlen($dom)) != $dom) {
|
82 |
+
// Not the source domain
|
83 |
+
// echo "<span style='color:#000;'># $url </span><br />";
|
84 |
+
} elseif ($nb_base_news) {
|
85 |
+
// Already in the database
|
86 |
+
// echo "<span style='color:#FFA500;'># $url </span><br />";
|
87 |
+
} elseif (substr_count($url, "-") > 6 && substr_count($url, $dom) && !substr_count( $url, '.jpg' ) && !substr_count( $url, '.png' ) && !substr_count( $url, 'mailto' ) ) {
|
88 |
+
// Add the link to the database
|
89 |
+
echo "<span style='color:#008000;'># $url </span><br />";
|
90 |
+
$insertQuery = "INSERT INTO `base_news` (`id`, `key_media`, `media`, `url`, `step`) VALUES (NULL, '$key', '$id_media', '$url', '0');";
|
91 |
+
mysqli_query($mysqli, $insertQuery);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
// Refresh the page
|
96 |
+
echo "<script type=\"text/javascript\">location.href='" . $_SERVER['REQUEST_URI'] . "';</script>";
|
97 |
+
|
98 |
+
?>
|
99 |
+
|
extract_news/old/database.sql
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--
|
2 |
+
-- Structure de la table `base_media`
|
3 |
+
--
|
4 |
+
|
5 |
+
DROP TABLE IF EXISTS `base_media`;
|
6 |
+
CREATE TABLE IF NOT EXISTS `base_media` (
|
7 |
+
`id` int NOT NULL AUTO_INCREMENT,
|
8 |
+
`url` varchar(255) NOT NULL,
|
9 |
+
`nb` int NOT NULL,
|
10 |
+
`last` int NOT NULL,
|
11 |
+
PRIMARY KEY (`id`)
|
12 |
+
) ENGINE=MyISAM CHARSET=utf8mb4;
|
13 |
+
|
14 |
+
--
|
15 |
+
-- Déchargement des données de la table `base_media`
|
16 |
+
--
|
17 |
+
|
18 |
+
INSERT INTO `base_media` (`id`, `url`, `nb`, `last`) VALUES
|
19 |
+
(1, 'https://www.lemonde.fr/rss/une.xml', 0, 0),
|
20 |
+
(2, 'https://www.liberation.fr/arc/outboundfeeds/collection/accueil-une/?outputType=xml', 0, 0),
|
21 |
+
(3, 'https://www.lemonde.fr/international/rss_full.xml', 0, 0),
|
22 |
+
(4, 'https://www.lemonde.fr/europe/rss_full.xml', 0, 0),
|
23 |
+
(5, 'https://www.lemonde.fr/politique/rss_full.xml', 0, 0),
|
24 |
+
(6, 'https://www.lemonde.fr/economie/rss_full.xml', 0, 0),
|
25 |
+
(7, 'https://www.lemonde.fr/culture/rss_full.xml', 0, 0),
|
26 |
+
(8, 'https://www.lemonde.fr/sport/rss_full.xml', 0, 0),
|
27 |
+
(9, 'https://www.lemonde.fr/sciences/rss_full.xml', 0, 0),
|
28 |
+
(10, 'https://www.lemonde.fr/rss/en_continu.xml', 0, 0),
|
29 |
+
(15, 'https://www.bfmtv.com/rss/news-24-7/', 0, 0),
|
30 |
+
(16, 'https://www.bfmtv.com/rss/international/', 0, 0),
|
31 |
+
(17, 'https://www.bfmtv.com/rss/politique/', 0, 0),
|
32 |
+
(18, 'https://www.bfmtv.com/rss/sciences/', 0, 0),
|
33 |
+
(19, 'https://www.bfmtv.com/rss/police-justice/', 0, 0),
|
34 |
+
(20, 'https://www.bfmtv.com/rss/people/cinema/', 0, 0),
|
35 |
+
(21, 'https://www.bfmtv.com/rss/tech/', 0, 0),
|
36 |
+
(22, 'https://www.bfmtv.com/rss/economie/', 0, 0),
|
37 |
+
(23, 'https://www.bfmtv.com/rss/paris/', 0, 0),
|
38 |
+
(24, 'https://www.bfmtv.com/rss/lyon/', 0, 0),
|
39 |
+
(25, 'https://www.bfmtv.com/rss/grand-lille/', 0, 0),
|
40 |
+
(26, 'https://www.bfmtv.com/rss/grand-littoral/', 0, 0),
|
41 |
+
(27, 'https://www.bfmtv.com/rss/marseille/', 0, 0),
|
42 |
+
(28, 'https://www.bfmtv.com/rss/var/', 0, 0),
|
43 |
+
(29, 'https://www.bfmtv.com/rss/cote-d-azur/', 0, 0),
|
44 |
+
(30, 'https://www.bfmtv.com/rss/toulouse/', 0, 0),
|
45 |
+
(31, 'https://www.bfmtv.com/rss/ajaccio/', 0, 0),
|
46 |
+
(32, 'https://www.bfmtv.com/rss/auxerre/', 0, 0),
|
47 |
+
(33, 'https://www.bfmtv.com/rss/bastia/', 0, 0),
|
48 |
+
(34, 'https://www.bfmtv.com/rss/besancon/', 0, 0),
|
49 |
+
(35, 'https://www.bfmtv.com/rss/bordeaux/', 0, 0),
|
50 |
+
(36, 'https://www.bfmtv.com/rss/brest/', 0, 0),
|
51 |
+
(37, 'https://www.bfmtv.com/rss/caen/', 0, 0),
|
52 |
+
(38, 'https://www.bfmtv.com/rss/clermont-ferrand/', 0, 0),
|
53 |
+
(39, 'https://www.bfmtv.com/rss/dijon/', 0, 0),
|
54 |
+
(40, 'https://www.bfmtv.com/rss/grenoble/', 0, 0),
|
55 |
+
(41, 'https://www.bfmtv.com/rss/la-rochelle/', 0, 0),
|
56 |
+
(42, 'https://www.bfmtv.com/rss/le-havre/', 0, 0),
|
57 |
+
(43, 'https://www.bfmtv.com/rss/limoges/', 0, 0),
|
58 |
+
(44, 'https://www.bfmtv.com/rss/metz/', 0, 0),
|
59 |
+
(45, 'https://www.bfmtv.com/rss/montpellier/', 0, 0),
|
60 |
+
(46, 'https://www.bfmtv.com/rss/nancy/', 0, 0),
|
61 |
+
(47, 'https://www.bfmtv.com/rss/nantes/', 0, 0),
|
62 |
+
(48, 'https://www.bfmtv.com/rss/orleans/', 0, 0),
|
63 |
+
(49, 'https://www.bfmtv.com/rss/poitiers/', 0, 0),
|
64 |
+
(50, 'https://www.bfmtv.com/rss/reims/', 0, 0),
|
65 |
+
(51, 'https://www.bfmtv.com/rss/rennes/', 0, 0),
|
66 |
+
(52, 'https://www.bfmtv.com/rss/saint-etienne/', 0, 0),
|
67 |
+
(53, 'https://www.bfmtv.com/rss/strasbourg/', 0, 0),
|
68 |
+
(54, 'https://www.bfmtv.com/rss/tours/', 0, 0),
|
69 |
+
(55, 'https://www.cnews.fr/rss.xml', 0, 0),
|
70 |
+
(56, 'https://www.francetvinfo.fr/titres.rss', 0, 0),
|
71 |
+
(57, 'https://www.francetvinfo.fr/france.rss', 0, 0),
|
72 |
+
(58, 'https://www.francetvinfo.fr/politique.rss', 0, 0),
|
73 |
+
(59, 'https://www.francetvinfo.fr/societe.rss', 0, 0),
|
74 |
+
(60, 'https://www.francetvinfo.fr/faits-divers.rss', 0, 0),
|
75 |
+
(61, 'https://www.francetvinfo.fr/justice.rss', 0, 0),
|
76 |
+
(62, 'https://www.francetvinfo.fr/monde.rss', 0, 0),
|
77 |
+
(63, 'https://www.francetvinfo.fr/economie.rss', 0, 0),
|
78 |
+
(64, 'https://www.francetvinfo.fr/sports.rss', 0, 0),
|
79 |
+
(65, 'https://www.francetvinfo.fr/decouverte.rss', 0, 0),
|
80 |
+
(66, 'https://www.francetvinfo.fr/culture.rss', 0, 0),
|
81 |
+
(67, 'https://www.france24.com/fr/rss', 0, 0),
|
82 |
+
(68, 'https://www.france24.com/fr/europe/rss', 0, 0),
|
83 |
+
(69, 'https://www.france24.com/fr/france/rss', 0, 0),
|
84 |
+
(70, 'https://www.france24.com/fr/afrique/rss', 0, 0),
|
85 |
+
(71, 'https://www.france24.com/fr/moyen-orient/rss', 0, 0),
|
86 |
+
(72, 'https://www.france24.com/fr/ameriques/rss', 0, 0),
|
87 |
+
(73, 'https://www.france24.com/fr/asie-pacifique/rss', 0, 0),
|
88 |
+
(74, 'https://www.france24.com/fr/economie/rss', 0, 0),
|
89 |
+
(75, 'https://www.france24.com/fr/sports/rss', 0, 0),
|
90 |
+
(76, 'https://www.france24.com/fr/culture/rss', 0, 0),
|
91 |
+
(77, 'https://www.lefigaro.fr/rss/figaro_actualites.xml', 0, 0),
|
92 |
+
(78, 'https://www.lefigaro.fr/rss/figaro_politique.xml', 0, 0),
|
93 |
+
(79, 'https://www.lefigaro.fr/rss/figaro_elections.xml', 0, 0),
|
94 |
+
(80, 'https://www.lefigaro.fr/rss/figaro_international.xml', 0, 0),
|
95 |
+
(81, 'https://www.lefigaro.fr/rss/figaro_actualite-france.xml', 0, 0),
|
96 |
+
(82, 'https://www.lefigaro.fr/rss/figaro_sciences.xml', 0, 0),
|
97 |
+
(83, 'https://www.lefigaro.fr/rss/figaro_economie.xml', 0, 0),
|
98 |
+
(84, 'https://www.lefigaro.fr/rss/figaro_culture.xml', 0, 0),
|
99 |
+
(85, 'https://www.lefigaro.fr/rss/figaro_flash-actu.xml', 0, 0),
|
100 |
+
(86, 'https://www.lefigaro.fr/rss/figaro_sport.xml', 0, 0),
|
101 |
+
(87, 'https://www.rtl.fr/sitemap-news.xml', 0, 0),
|
102 |
+
(88, 'https://www.tf1info.fr/sitemap-n.xml', 0, 0),
|
103 |
+
(89, 'https://www.latribune.fr/feed.xml', 0, 0),
|
104 |
+
(90, 'https://www.humanite.fr/rss/actu.rss', 0, 0),
|
105 |
+
(91, 'https://www.la-croix.com/RSS/UNIVERS', 0, 0),
|
106 |
+
(92, 'https://www.la-croix.com/RSS/UNIVERS_WFRA', 0, 0),
|
107 |
+
(93, 'https://www.la-croix.com/RSS/WMON-EUR', 0, 0),
|
108 |
+
(94, 'https://www.la-croix.com/RSS/WECO-MON', 0, 0),
|
109 |
+
(95, 'https://www.nicematin.com/googlenews.xml', 0, 0),
|
110 |
+
(96, 'https://www.ouest-france.fr/rss/une', 0, 0),
|
111 |
+
(97, 'https://www.midilibre.fr/rss.xml', 0, 0),
|
112 |
+
(99, 'https://www.laprovence.com/googlenews.xml', 0, 0),
|
113 |
+
(100, 'https://www.sudouest.fr/rss.xml', 0, 0),
|
114 |
+
(101, 'https://www.sudouest.fr/culture/cinema/rss.xml', 0, 0),
|
115 |
+
(102, 'https://www.sudouest.fr/economie/rss.xml', 0, 0),
|
116 |
+
(103, 'https://www.sudouest.fr/faits-divers/rss.xml', 0, 0),
|
117 |
+
(104, 'https://www.sudouest.fr/politique/rss.xml', 0, 0),
|
118 |
+
(105, 'https://www.sudouest.fr/sport/rss.xml', 0, 0),
|
119 |
+
(98, 'https://feeds.leparisien.fr/leparisien/rss', 0, 0),
|
120 |
+
(107, 'https://www.lexpress.fr/sitemap_actu_1.xml', 0, 0),
|
121 |
+
(108, 'https://www.lepoint.fr/rss.xml', 0, 0),
|
122 |
+
(109, 'https://www.lepoint.fr/politique/rss.xml', 0, 0),
|
123 |
+
(110, 'https://www.lepoint.fr/monde/rss.xml', 0, 0),
|
124 |
+
(111, 'https://www.lepoint.fr/societe/rss.xml', 0, 0),
|
125 |
+
(112, 'https://www.lepoint.fr/economie/rss.xml', 0, 0),
|
126 |
+
(113, 'https://www.lepoint.fr/medias/rss.xml', 0, 0),
|
127 |
+
(114, 'https://www.lepoint.fr/science/rss.xml', 0, 0),
|
128 |
+
(115, 'https://www.lepoint.fr/sport/rss.xml', 0, 0),
|
129 |
+
(116, 'https://www.lepoint.fr/high-tech-internet/rss.xml', 0, 0),
|
130 |
+
(117, 'https://www.lepoint.fr/culture/rss.xml', 0, 0),
|
131 |
+
(118, 'https://www.nouvelobs.com/sport/rss.xml', 0, 0),
|
132 |
+
(119, 'https://www.nouvelobs.com/societe/rss.xml', 0, 0),
|
133 |
+
(120, 'https://www.nouvelobs.com/politique/rss.xml', 0, 0),
|
134 |
+
(121, 'https://www.nouvelobs.com/justice/rss.xml', 0, 0),
|
135 |
+
(122, 'https://www.nouvelobs.com/faits-divers/rss.xml', 0, 0),
|
136 |
+
(123, 'https://www.nouvelobs.com/economie/rss.xml', 0, 0),
|
137 |
+
(124, 'https://www.nouvelobs.com/culture/rss.xml', 0, 0),
|
138 |
+
(125, 'https://www.nouvelobs.com/monde/rss.xml', 0, 0),
|
139 |
+
(161, 'https://www.football365.fr/feed', 0, 0),
|
140 |
+
(127, 'https://www.europe1.fr/rss.xml', 0, 0),
|
141 |
+
(128, 'https://www.europe1.fr/rss/sport.xml', 0, 0),
|
142 |
+
(129, 'https://www.europe1.fr/rss/politique.xml', 0, 0),
|
143 |
+
(130, 'https://www.europe1.fr/rss/international.xml', 0, 0),
|
144 |
+
(131, 'https://www.europe1.fr/rss/technologies.xml', 0, 0),
|
145 |
+
(132, 'https://www.europe1.fr/rss/faits-divers.xml', 0, 0),
|
146 |
+
(133, 'https://www.europe1.fr/rss/economie.xml', 0, 0),
|
147 |
+
(134, 'https://www.europe1.fr/rss/culture.xml', 0, 0),
|
148 |
+
(135, 'https://www.europe1.fr/rss/societe.xml', 0, 0),
|
149 |
+
(136, 'https://www.europe1.fr/rss/sciences.xml', 0, 0),
|
150 |
+
(137, 'https://www.europe1.fr/rss/insolite.xml', 0, 0),
|
151 |
+
(138, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/belgique/?outputType=xml', 0, 0),
|
152 |
+
(139, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/economie/?outputType=xml', 0, 0),
|
153 |
+
(140, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/international/?outputType=xml', 0, 0),
|
154 |
+
(141, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/culture/?outputType=xml', 0, 0),
|
155 |
+
(142, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/sports/?outputType=xml', 0, 0),
|
156 |
+
(143, 'https://www.lalibre.be/arc/outboundfeeds/rss/section/regions/?outputType=xml', 0, 0),
|
157 |
+
(144, 'https://www.courrierinternational.com/feed/all/rss.xml', 0, 0),
|
158 |
+
(145, 'https://www.20minutes.fr/feeds/rss-une.xml', 0, 0),
|
159 |
+
(146, 'https://www.huffingtonpost.fr/rss/all_headline.xml', 0, 0),
|
160 |
+
(147, 'https://fr.euronews.com/sitemaps/fr/latest-news.xml', 0, 0),
|
161 |
+
(148, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/belgique/?outputType=xml', 0, 0),
|
162 |
+
(149, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/faits/?outputType=xml', 0, 0),
|
163 |
+
(150, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/societe/?outputType=xml', 0, 0),
|
164 |
+
(151, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/monde/?outputType=xml', 0, 0),
|
165 |
+
(152, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/actu/economie/?outputType=xml', 0, 0),
|
166 |
+
(153, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/sports/?outputType=xml', 0, 0),
|
167 |
+
(154, 'https://www.dhnet.be/arc/outboundfeeds/rss/section/regions/?outputType=xml', 0, 0),
|
168 |
+
(155, 'https://www.rtbf.be/site-map/articles.xml', 0, 0),
|
169 |
+
(156, 'https://www.lematin.ch/sitemaps/fr/news.xml', 0, 0),
|
170 |
+
(157, 'https://www.24heures.ch/sitemaps/news.xml', 0, 0),
|
171 |
+
(158, 'https://www.20min.ch/sitemaps/fr/news.xml', 0, 0),
|
172 |
+
(159, 'https://www.tdg.ch/sitemaps/news.xml', 0, 0),
|
173 |
+
(160, 'https://www.lequipe.fr/sitemap/sitemap_google_news_gratuit.xml', 0, 0),
|
174 |
+
(162, 'http://feeds.feedburner.com/SoFoot', 0, 0),
|
175 |
+
(163, 'https://rmcsport.bfmtv.com/rss/football/', 0, 0),
|
176 |
+
(164, 'https://rmcsport.bfmtv.com/rss/rugby/', 0, 0),
|
177 |
+
(165, 'https://rmcsport.bfmtv.com/rss/basket/', 0, 0),
|
178 |
+
(166, 'https://rmcsport.bfmtv.com/rss/tennis/', 0, 0),
|
179 |
+
(167, 'https://rmcsport.bfmtv.com/rss/cyclisme/', 0, 0),
|
180 |
+
(168, 'https://rmcsport.bfmtv.com/rss/auto-moto/f1/', 0, 0),
|
181 |
+
(169, 'https://rmcsport.bfmtv.com/rss/handball/', 0, 0),
|
182 |
+
(170, 'https://rmcsport.bfmtv.com/rss/jeux-olympiques/', 0, 0),
|
183 |
+
(171, 'https://rmcsport.bfmtv.com/rss/football/ligue-1/', 0, 0),
|
184 |
+
(172, 'https://rmcsport.bfmtv.com/rss/sports-de-combat/', 0, 0),
|
185 |
+
(174, 'https://www.francebleu.fr/rss/a-la-une.xml', 0, 0),
|
186 |
+
(175, 'https://www.journaldunet.com/rss/', 0, 0),
|
187 |
+
(176, 'https://www.lindependant.fr/rss.xml', 0, 0),
|
188 |
+
(177, 'https://www.lopinion.fr/index.rss', 0, 0),
|
189 |
+
(178, 'https://www.marianne.net/rss.xml', 0, 0),
|
190 |
+
(179, 'https://www.01net.com/actualites/feed/', 0, 0),
|
191 |
+
(181, 'https://www.brut.media/fr/rss', 0, 0),
|
192 |
+
(182, 'https://www.lamontagne.fr/sitemap.xml', 0, 0),
|
193 |
+
(183, 'https://www.science-et-vie.com/feed', 0, 0),
|
194 |
+
(184, 'https://fr.motorsport.com/rss/all/news/', 0, 0),
|
195 |
+
(185, 'https://www.presse-citron.net/feed/', 0, 0),
|
196 |
+
(186, 'https://www.valeursactuelles.com/feed?post_type=post&taxonomy_name=cult', 0, 0),
|
197 |
+
(187, 'https://www.valeursactuelles.com/feed?post_type=post&taxonomy_name=faits-di', 0, 0),
|
198 |
+
(188, 'https://www.larepubliquedespyrenees.fr/actualite/rss.xml', 0, 0),
|
199 |
+
(189, 'https://actu17.fr/feed', 0, 0),
|
200 |
+
(191, 'https://www.futura-sciences.com/rss/actualites.xml', 0, 0),
|
201 |
+
(192, 'https://www.techno-science.net/include/news.xml', 0, 0),
|
202 |
+
(193, 'https://trashtalk.co/feed', 0, 0),
|
203 |
+
(194, 'https://regards.fr/feed/', 0, 0),
|
204 |
+
(195, 'https://www.allocine.fr/rss/news.xml', 0, 0),
|
205 |
+
(229, 'https://www.jeuxvideo.com/rss/rss.xml', 0, 0),
|
206 |
+
(230, 'https://www.clubic.com/feed/news.rss', 0, 0),
|
207 |
+
(231, 'https://www.letelegramme.fr/rss.xml', 0, 0),
|
208 |
+
(232, 'https://www.sciencesetavenir.fr/rss.xml', 0, 0),
|
209 |
+
(200, 'https://www.onzemondial.com/rss/index.html', 0, 0),
|
210 |
+
(226, 'https://www.petitbleu.fr/rss.xml', 0, 0),
|
211 |
+
(227, 'https://www.centrepresseaveyron.fr/rss.xml', 0, 0),
|
212 |
+
(228, 'https://www.toulouscope.fr/rss.xml', 0, 0),
|
213 |
+
(205, 'https://www.7sur7.be/people/rss.xml', 0, 0),
|
214 |
+
(206, 'https://www.7sur7.be/sport/rss.xml', 0, 0),
|
215 |
+
(207, 'https://www.7sur7.be/monde/rss.xml', 0, 0),
|
216 |
+
(208, 'https://www.7sur7.be/belgique/rss.xml', 0, 0),
|
217 |
+
(210, 'https://cdn-elle.ladmedia.fr/var/plain_site/storage/flux_rss/fluxToutELLEfr.xml', 0, 0),
|
218 |
+
(211, 'https://www.santemagazine.fr/feeds/rss', 0, 0),
|
219 |
+
(212, 'https://www.santemagazine.fr/feeds/rss/actualites', 0, 0),
|
220 |
+
(214, 'https://www.abcbourse.com/rss/displaynewsrss', 0, 0),
|
221 |
+
(213, 'https://actu.fr/rss.xml', 0, 0),
|
222 |
+
(225, 'https://www.rugbyrama.fr/rss.xml', 0, 0),
|
223 |
+
(224, 'https://www.ladepeche.fr/rss.xml', 0, 0),
|
224 |
+
(235, 'https://services.lesechos.fr/rss/les-echos-economie.xml', 0, 0),
|
225 |
+
(223, 'https://www.femmeactuelle.fr/feeds/rss.xml', 0, 0),
|
226 |
+
(233, 'https://air-cosmos.com/rss', 0, 0),
|
227 |
+
(236, 'https://services.lesechos.fr/rss/les-echos-entreprises.xml', 0, 0),
|
228 |
+
(237, 'https://services.lesechos.fr/rss/les-echos-finance-marches.xml', 0, 0),
|
229 |
+
(238, 'https://www.numerama.com/feed/', 0, 0);
|
230 |
+
COMMIT;
|
231 |
+
|
232 |
+
-- --------------------------------------------------------
|
233 |
+
|
234 |
+
--
|
235 |
+
-- Structure de la table `base_news`
|
236 |
+
--
|
237 |
+
|
238 |
+
DROP TABLE IF EXISTS `base_news`;
|
239 |
+
CREATE TABLE IF NOT EXISTS `base_news` (
|
240 |
+
`id` int NOT NULL AUTO_INCREMENT,
|
241 |
+
`key_media` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
242 |
+
`key_title` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
243 |
+
`media` int NOT NULL,
|
244 |
+
`title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
245 |
+
`txt_clean` text NOT NULL,
|
246 |
+
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
247 |
+
`link` tinyint NOT NULL,
|
248 |
+
`step` tinyint NOT NULL,
|
249 |
+
PRIMARY KEY (`id`),
|
250 |
+
KEY `url` (`url`(250)),
|
251 |
+
KEY `key_title` (`key_title`),
|
252 |
+
KEY `key_media` (`key_media`),
|
253 |
+
KEY `media` (`media`)
|
254 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
255 |
+
COMMIT;
|
256 |
+
|
extract_news/old/functions_mysqli.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
#####################################################################
|
4 |
+
###################### Base fonctions mysqli ####################
|
5 |
+
#####################################################################
|
6 |
+
|
7 |
+
|
8 |
+
$mysqli = new mysqli("[host]", "[user]", "[passwd]", "[database]");
|
9 |
+
if ($mysqli->connect_errno) {
|
10 |
+
echo "Failed to connect to MySQL : (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
|
11 |
+
}
|
12 |
+
|
13 |
+
function mysqli_return_number( $mysqli, $req ){
|
14 |
+
|
15 |
+
$row_cnt = 0;
|
16 |
+
if ( $result = $mysqli->query( "$req" ) ) {
|
17 |
+
|
18 |
+
$row_cnt = $result->num_rows;
|
19 |
+
$result->close();
|
20 |
+
}
|
21 |
+
return $row_cnt;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
?>
|
extract_news/utils.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mysql.connector
|
2 |
+
from mysql.connector import Error
|
3 |
+
import os, re
|
4 |
+
|
5 |
+
### db
|
6 |
+
def create_connection(config):
|
7 |
+
""" Establishes a connection to the database and returns the connection object. """
|
8 |
+
try:
|
9 |
+
conn = mysql.connector.connect(**config)
|
10 |
+
if conn.is_connected():
|
11 |
+
print("Successfully connected to the database")
|
12 |
+
return conn
|
13 |
+
except Error as e:
|
14 |
+
print(f"Error connecting to MySQL: {e}")
|
15 |
+
return None
|
16 |
+
|
17 |
+
def mysqli_return_number(conn, query):
|
18 |
+
cursor = conn.cursor()
|
19 |
+
cursor.execute(query)
|
20 |
+
result = cursor.fetchone()
|
21 |
+
cursor.close()
|
22 |
+
return result[0] if result else 0
|
23 |
+
|
24 |
+
### Files
|
25 |
+
def save_to_file(path, data):
|
26 |
+
with open(path, "w", encoding='utf-8', errors='ignore') as file:
|
27 |
+
file.write(data)
|
28 |
+
|
29 |
+
def get_file_content(file_path):
|
30 |
+
if os.path.exists(file_path):
|
31 |
+
with open(file_path, 'r', encoding='utf8', errors='ignore') as file:
|
32 |
+
return file.read()
|
33 |
+
else:
|
34 |
+
return ''
|
35 |
+
|
36 |
+
### clean text functions
|
37 |
+
def clean_text(text):
|
38 |
+
replacements = {
|
39 |
+
chr(8217): "'",
|
40 |
+
"`": "'",
|
41 |
+
"’": "'"
|
42 |
+
}
|
43 |
+
for orig, repl in replacements.items():
|
44 |
+
text = text.replace(orig, repl)
|
45 |
+
|
46 |
+
allowed_chars = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/*-+.$*ù^£–—“”—" +
|
47 |
+
"µ%¨!:;,?./§&é\"'(è_çàâ)=°ç[{#}]¤~²ôûîïäëêíáã•©®€¢¥ƒÁÂÀÅÃäÄæÇÉÊÈËÍîÎñÑÓÔóÒøØõÕö" +
|
48 |
+
"ÖœŒšŠßðÐþÞÚúûÛùÙüÜýÝÿŸαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ×÷" +
|
49 |
+
"±∓≠<>≤≥≈∝∞∫∑∈∉⊆⊇⊂⊃∪∩∧∨¬∀∃π×⨯⊗→←↑↓↔ ϒϖϑℵ⟩⟨⋅⊗⊄≅∗∉∅⇓⇑⇐↵ℜℑ℘⊕⊥∼∴∪∨∧∠∝" +
|
50 |
+
"∋∈∇∃∀⇔⇒∩¬∞√∑∏∂″′ªº³²¹¾½¼‰¶‡†¿§«»@")
|
51 |
+
text = ''.join(c if c in allowed_chars else ' ' for c in text)
|
52 |
+
remove = ['. .', '..', "?.", "!.", ";.", "??", "? ?", ]
|
53 |
+
for phrase in remove:
|
54 |
+
text = text.replace(phrase, phrase[0] + ' ')
|
55 |
+
text = re.sub(r' ', " ", text)
|
56 |
+
text = re.sub(r'&#(x[0-9a-fA-F]+|\d+);', ' ', text)
|
57 |
+
text = re.sub(r'&#\d+;', ' ', text)
|
58 |
+
text = re.sub(r'\s{2,}', ' ', text)
|
59 |
+
replacements = {
|
60 |
+
"À": "À",
|
61 |
+
"Â": "Â",
|
62 |
+
"Ã": "Ã",
|
63 |
+
"Ä": "Ä",
|
64 |
+
"Â": "Â",
|
65 |
+
"Ã…": "Å",
|
66 |
+
"á": "á",
|
67 |
+
"â": "â",
|
68 |
+
"ã": "ã",
|
69 |
+
"ä": "ä",
|
70 |
+
"Ã¥": "å",
|
71 |
+
"Ã’": "Ò",
|
72 |
+
"Ó": "Ó",
|
73 |
+
"Ô": "Ô",
|
74 |
+
"Õ": "Õ",
|
75 |
+
"Ö": "Ö",
|
76 |
+
"Ø": "Ø",
|
77 |
+
"ò": "ò",
|
78 |
+
"ó": "ó",
|
79 |
+
"ô": "ô",
|
80 |
+
"õ": "õ",
|
81 |
+
"ö": "ö",
|
82 |
+
"ø": "ø",
|
83 |
+
"È": "È",
|
84 |
+
"É": "É",
|
85 |
+
"Ê": "Ê",
|
86 |
+
"Ë": "Ë",
|
87 |
+
"è": "è",
|
88 |
+
"é": "é",
|
89 |
+
"ê": "ê",
|
90 |
+
"ë": "ë",
|
91 |
+
"Ç": "Ç",
|
92 |
+
"ç": "ç",
|
93 |
+
"ÃŒ": "Ì",
|
94 |
+
"ÃŽ": "Î",
|
95 |
+
"ì": "ì",
|
96 |
+
"Ã": "í",
|
97 |
+
"î": "î",
|
98 |
+
"ï": "ï",
|
99 |
+
"Ù": "Ù",
|
100 |
+
"Ú": "Ú",
|
101 |
+
"Û": "Û",
|
102 |
+
"Ãœ": "Ü",
|
103 |
+
"ù": "ù",
|
104 |
+
"ú": "ú",
|
105 |
+
"û": "û",
|
106 |
+
"ü": "ü",
|
107 |
+
"ÿ": "ÿ",
|
108 |
+
"Ñ": "Ñ",
|
109 |
+
"ñ": "ñ",
|
110 |
+
"Ã": "Á",
|
111 |
+
"Ã": "Í",
|
112 |
+
"Ã ": "à",
|
113 |
+
'’': '\'',
|
114 |
+
"«": "«",
|
115 |
+
'»': '»'
|
116 |
+
}
|
117 |
+
|
118 |
+
for key, value in replacements.items():
|
119 |
+
text = text.replace(key, value)
|
120 |
+
return text
|
121 |
+
|
122 |
+
def decode_unicode_escapes(s):
|
123 |
+
def decode_match(match):
|
124 |
+
return bytes(match.group(0), "utf-8").decode("unicode_escape")
|
125 |
+
return re.sub(r'(\\u[0-9a-fA-F]{4})', decode_match, s)
|
126 |
+
|
127 |
+
def decode_content(content_bytes):
|
128 |
+
for encoding in ['utf-8-sig', 'mac_roman', 'ascii', 'windows-1254', 'windows-1252']:
|
129 |
+
try:
|
130 |
+
return content_bytes.decode(encoding)
|
131 |
+
except UnicodeDecodeError:
|
132 |
+
continue
|
133 |
+
return None
|
134 |
+
|