import requests from bs4 import BeautifulSoup # URL der Zielseite (Eurojackpot bei ARD-Text) url = "https://lotto.gmx.de/eurojackpot/zahlen-quoten" # HTTP-Request senden response = requests.get(url) response.raise_for_status() # Fehlerprüfung # HTML mit BeautifulSoup parsen soup = BeautifulSoup(response.text, "html.parser") # Formatierten HTML-Code ausgeben formatted_html = soup.prettify() # Ausgabe in der Konsole #print(formatted_html) url = "https://lotto.gmx.de/eurojackpot/zahlen-quoten" response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") # Finde den ersten div mit einer bestimmten Klasse html_code = soup.find("div", class_="std") print(html_code) # HTML parsen soup = BeautifulSoup(response.text, "html.parser") # Robust: finde -Tag mit "Gewinnzahlen" (normalisiert auf Whitespace!) b_tag = soup.find("b", string=lambda s: s and "gewinnzahlen" in s.lower()) if b_tag: table = b_tag.find_parent().find_next_sibling("table") if table: gewinnzahlen = [int(td.get_text(strip=True)) for td in table.find_all("td")] print("Gewinnzahlen:", gewinnzahlen) else: print("Tabelle nicht gefunden.") else: print("Gewinnzahlen nicht gefunden.")