Public Access
Mise a jour module éduction nationale
Build and Push Docker Image / build-and-push (push) Successful in 36s
Build and Push Docker Image / build-and-push (push) Successful in 36s
This commit is contained in:
1 parent
06c74ee4a5
commit
dd5cd760e0
1 file changed
+8
-3
@@ -11,16 +11,21 @@ def maj_base_education():
|
||||
os.makedirs(RAG_DIR, exist_ok=True)
|
||||
url_rss = "https://www.education.gouv.fr/bo/rss.xml"
|
||||
|
||||
# En-têtes complets simulant un navigateur pour éviter le blocage 403
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
"Accept": "application/rss+xml,application/xml;q=0.9,text/html;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(url_rss, timeout=15)
|
||||
response = requests.get(url_rss, headers=headers, timeout=15)
|
||||
if response.status_code == 200:
|
||||
root = ET.fromstring(response.content)
|
||||
|
||||
# Formatage pour une ingestion parfaite par le RAG
|
||||
contenu_md = f"# Veille Pédagogique - Bulletin Officiel (B.O.)\n"
|
||||
contenu_md += f"*Date de mise à jour RAG : {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n\n"
|
||||
|
||||
# On extrait les 20 dernières circulaires/textes de loi
|
||||
for item in root.findall('.//item')[:20]:
|
||||
titre = item.find('title').text if item.find('title') is not None else "Document sans titre"
|
||||
lien = item.find('link').text if item.find('link') is not None else "Aucun lien"
|
||||
|
||||
Reference in new issue
Block a user