add extractor viparis
This commit is contained in:
parent
fd2d51b662
commit
ee48a3c665
9 changed files with 2221 additions and 4443 deletions
|
@ -106,7 +106,7 @@ class CCPLAgendaScraper:
|
|||
cached_hash = self.cache_data.get("content_hash")
|
||||
return cached_hash != new_hash
|
||||
|
||||
def fetch_agenda_data(self) -> Optional[str]:
|
||||
def fetch_agenda_data(self, force_refresh: bool = False) -> Optional[str]:
|
||||
"""Récupère les données de l'agenda CCPL"""
|
||||
try:
|
||||
logger.info(f"🌐 Récupération de l'agenda CCPL: {self.agenda_url}")
|
||||
|
@ -121,9 +121,12 @@ class CCPLAgendaScraper:
|
|||
content = response.text
|
||||
content_hash = self.get_content_hash(content)
|
||||
|
||||
# Vérifier si le contenu a changé
|
||||
if self.is_content_changed(content_hash):
|
||||
logger.info("🔄 Nouveau contenu détecté, mise à jour du cache")
|
||||
# Vérifier si le contenu a changé ou si on force le rafraîchissement
|
||||
if self.is_content_changed(content_hash) or force_refresh:
|
||||
if force_refresh:
|
||||
logger.info("🔄 Rafraîchissement forcé, mise à jour du cache")
|
||||
else:
|
||||
logger.info("🔄 Nouveau contenu détecté, mise à jour du cache")
|
||||
self.cache_data["content_hash"] = content_hash
|
||||
self.cache_data["last_fetch"] = datetime.now().isoformat()
|
||||
self.save_cache_data()
|
||||
|
@ -282,7 +285,7 @@ class CCPLAgendaScraper:
|
|||
"label": title,
|
||||
"description": description,
|
||||
"type": "scheduled",
|
||||
"what": "culture.community",
|
||||
"what": "culture.community.ccpl",
|
||||
"where": location,
|
||||
"start": self.parse_date(date_text),
|
||||
"stop": self.parse_date(date_text, end=True),
|
||||
|
@ -894,7 +897,7 @@ class CCPLAgendaScraper:
|
|||
|
||||
try:
|
||||
# Récupérer les données de l'agenda
|
||||
html_content = self.fetch_agenda_data()
|
||||
html_content = self.fetch_agenda_data(force_refresh)
|
||||
|
||||
if html_content is None and not force_refresh:
|
||||
logger.info("ℹ️ Utilisation du cache (pas de nouveau contenu)")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue