scrape_fotograf.py aktualisiert
This commit is contained in:
@@ -17,14 +17,17 @@ OUTPUT_FILE = os.path.join(OUTPUT_DIR, 'nutzer_ohne_logins.csv')
|
|||||||
LOGIN_URL = 'https://app.fotograf.de/login/login'
|
LOGIN_URL = 'https://app.fotograf.de/login/login'
|
||||||
|
|
||||||
# --- Selektoren ---
|
# --- Selektoren ---
|
||||||
|
# FINALE, KORREKTE VERSION mit präzisem Album-Row-Selector
|
||||||
SELECTORS = {
|
SELECTORS = {
|
||||||
"cookie_accept_button": "#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll",
|
"cookie_accept_button": "#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll",
|
||||||
"login_user": "#login-email",
|
"login_user": "#login-email",
|
||||||
"login_pass": "#login-password",
|
"login_pass": "#login-password",
|
||||||
"login_button": "#login-submit",
|
"login_button": "#login-submit",
|
||||||
"job_name": "h1",
|
"job_name": "h1",
|
||||||
"album_rows": "div:has(a[href*='/config_jobs_photos/gallery/'])",
|
# NEU: Findet die Tabellen-Kopfzeile und wählt dann alle folgenden Zeilen als Geschwister aus.
|
||||||
|
"album_rows": "div:has(> div:contains('Fotos insgesamt')) ~ div",
|
||||||
"album_link": "a[href*='/config_jobs_photos/gallery/']",
|
"album_link": "a[href*='/config_jobs_photos/gallery/']",
|
||||||
|
# Dieser Selector sollte jetzt im korrekten Zeilen-Kontext funktionieren.
|
||||||
"login_count": "div:nth-child(7)",
|
"login_count": "div:nth-child(7)",
|
||||||
"buyer_link": "a.block:has(span:contains('Käufer'))",
|
"buyer_link": "a.block:has(span:contains('Käufer'))",
|
||||||
"buyer_email": "div.flex:nth-of-type(4) span"
|
"buyer_email": "div.flex:nth-of-type(4) span"
|
||||||
@@ -117,8 +120,12 @@ def process_job(driver, job_url):
|
|||||||
|
|
||||||
albums_to_process = []
|
albums_to_process = []
|
||||||
try:
|
try:
|
||||||
album_rows = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, SELECTORS["album_rows"])))
|
# Warten, bis die Kopfzeile da ist, um sicherzustellen, dass die Tabelle geladen ist
|
||||||
print(f"{len(album_rows)} Alben gefunden. Prüfe auf Logins...")
|
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div:contains('Fotos insgesamt')")))
|
||||||
|
time.sleep(1) # Kurze extra Wartezeit, falls die Zeilen nach der Kopfzeile nachladen
|
||||||
|
|
||||||
|
album_rows = driver.find_elements(By.CSS_SELECTOR, SELECTORS["album_rows"])
|
||||||
|
print(f"{len(album_rows)} Album-Zeilen gefunden. Prüfe auf Logins...")
|
||||||
|
|
||||||
for i, row in enumerate(album_rows):
|
for i, row in enumerate(album_rows):
|
||||||
print(f"\n--- Analysiere Zeile {i+1} ---")
|
print(f"\n--- Analysiere Zeile {i+1} ---")
|
||||||
@@ -148,16 +155,12 @@ def process_job(driver, job_url):
|
|||||||
print(f" --> FEHLER: Konnte Zeile nicht verarbeiten. Grund: {e}")
|
print(f" --> FEHLER: Konnte Zeile nicht verarbeiten. Grund: {e}")
|
||||||
|
|
||||||
except TimeoutException:
|
except TimeoutException:
|
||||||
print("Keine Alben auf der Seite gefunden oder Timeout beim Warten.")
|
print("Die Album-Tabelle wurde nicht gefunden.")
|
||||||
take_error_screenshot(driver, "album_list_timeout")
|
take_error_screenshot(driver, "album_list_timeout")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
print(f"\nVerarbeite {len(albums_to_process)} Alben mit 0 Logins im Detail...")
|
print(f"\nVerarbeite {len(albums_to_process)} Alben mit 0 Logins im Detail...")
|
||||||
if not albums_to_process:
|
|
||||||
# Hier geben wir die Funktion nur zurück, wenn keine Alben zu verarbeiten sind
|
|
||||||
pass # Placeholder
|
|
||||||
|
|
||||||
for album in albums_to_process:
|
for album in albums_to_process:
|
||||||
try:
|
try:
|
||||||
print(f" Rufe Detailseite für '{album['child_name']}' auf...")
|
print(f" Rufe Detailseite für '{album['child_name']}' auf...")
|
||||||
@@ -215,7 +218,6 @@ def get_profile_choice():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("--- Fotograf.de Scraper für Nutzer ohne Logins ---")
|
print("--- Fotograf.de Scraper für Nutzer ohne Logins ---")
|
||||||
# KORRIGIERTE ZEILE
|
|
||||||
credentials = get_profile_choice()
|
credentials = get_profile_choice()
|
||||||
if not credentials: return
|
if not credentials: return
|
||||||
job_url = input("Bitte gib die URL des zu bearbeitenden Fotoauftrags ein: ")
|
job_url = input("Bitte gib die URL des zu bearbeitenden Fotoauftrags ein: ")
|
||||||
|
|||||||
Reference in New Issue
Block a user