Version stable : Synthèse 3 cinémas avec affiches et horaires
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
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': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Accept-Language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||
}
|
||||
|
||||
def check_site(name, url):
|
||||
print(f"\n--- TEST {name.upper()} ---")
|
||||
try:
|
||||
r = requests.get(url, headers=HEADERS, timeout=10)
|
||||
print(f"Status Code: {r.status_code}")
|
||||
|
||||
if r.status_code != 200:
|
||||
print("ERREUR: Le site bloque ou ne répond pas.")
|
||||
return
|
||||
|
||||
soup = BeautifulSoup(r.content, 'html.parser')
|
||||
print(f"Taille du contenu téléchargé: {len(r.text)} caractères")
|
||||
|
||||
# Vérif si on est bloqué
|
||||
if "captcha" in r.text.lower() or "forbidden" in r.text.lower():
|
||||
print("ALERTE: Détection de blocage (Captcha/Forbidden) !")
|
||||
return
|
||||
|
||||
# Afficher les titres potentiels (H2, H3) pour voir la structure
|
||||
print("Recherche de balises titres (H2, H3, H4) :")
|
||||
titles = soup.find_all(['h2', 'h3', 'h4'])
|
||||
|
||||
found_count = 0
|
||||
for i, t in enumerate(titles[:10]): # On affiche les 10 premiers
|
||||
txt = t.get_text(" ", strip=True)
|
||||
if len(txt) > 3:
|
||||
print(f" [{t.name}] {txt}")
|
||||
found_count += 1
|
||||
|
||||
if found_count == 0:
|
||||
print(" AUCUN TITRE TROUVÉ. Le sélecteur CSS doit être revu.")
|
||||
# Affiche un bout du HTML pour comprendre
|
||||
print("\nExtrait du HTML (500 premiers caractères du body):")
|
||||
body = soup.find('body')
|
||||
print(body.prettify()[:500] if body else "Pas de body")
|
||||
|
||||
except Exception as e:
|
||||
print(f"ERREUR CRITIQUE: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_site("Cosmograph", "https://www.american-cosmograph.fr/les-horaires.html")
|
||||
check_site("Le Cratère", "https://www.cinemalecratere.fr/films")
|
||||
check_site("ABC", "https://abc-toulouse.fr/horaires.html")
|
||||
Reference in New Issue
Block a user