Schaut auch nach 1-er-Öffnungen
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import csv
|
import csv
|
||||||
import math
|
import math
|
||||||
|
import re # NEU: Modul für reguläre Ausdrücke importieren
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.options import Options
|
from selenium.webdriver.chrome.options import Options
|
||||||
@@ -14,7 +15,7 @@ from selenium.common.exceptions import TimeoutException, NoSuchElementException,
|
|||||||
# --- Konfiguration & Konstanten ---
|
# --- Konfiguration & Konstanten ---
|
||||||
CREDENTIALS_FILE = 'fotograf_credentials.json'
|
CREDENTIALS_FILE = 'fotograf_credentials.json'
|
||||||
OUTPUT_DIR = 'output'
|
OUTPUT_DIR = 'output'
|
||||||
OUTPUT_FILE = os.path.join(OUTPUT_DIR, 'nutzer_mit_wenig_logins.csv') # Dateiname angepasst
|
OUTPUT_FILE = os.path.join(OUTPUT_DIR, 'nutzer_mit_wenig_logins.csv')
|
||||||
LOGIN_URL = 'https://app.fotograf.de/login/login'
|
LOGIN_URL = 'https://app.fotograf.de/login/login'
|
||||||
|
|
||||||
# --- Selektoren (unverändert) ---
|
# --- Selektoren (unverändert) ---
|
||||||
@@ -98,13 +99,17 @@ def login(driver, username, password):
|
|||||||
def process_full_job(driver, job_url):
|
def process_full_job(driver, job_url):
|
||||||
wait = WebDriverWait(driver, 15)
|
wait = WebDriverWait(driver, 15)
|
||||||
|
|
||||||
print(f"\nVerarbeite Job-URL: {job_url}")
|
# Der Job-Name wird von der Einstellungs-Seite geholt, da diese stabil ist.
|
||||||
|
# Wir konstruieren die URL aus der eingegebenen URL, egal welche es war.
|
||||||
try:
|
try:
|
||||||
driver.get(job_url)
|
job_id = re.search(r'/(\d+)$', job_url).group(1)
|
||||||
except InvalidArgumentException:
|
settings_url = f"https://app.fotograf.de/config_jobs_settings/index/{job_id}"
|
||||||
print(f"!!! FEHLER: Die URL '{job_url}' wurde von Selenium als ungültig angesehen.")
|
except (AttributeError, IndexError):
|
||||||
|
print(f"!!! FEHLER: Konnte keine Job-ID aus der URL '{job_url}' extrahieren.")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
print(f"\nVerarbeite Job-ID: {job_id}")
|
||||||
|
driver.get(settings_url)
|
||||||
try:
|
try:
|
||||||
job_name = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, SELECTORS["job_name"]))).text
|
job_name = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, SELECTORS["job_name"]))).text
|
||||||
print(f"Auftragsname: '{job_name}'")
|
print(f"Auftragsname: '{job_name}'")
|
||||||
@@ -113,7 +118,6 @@ def process_full_job(driver, job_url):
|
|||||||
take_error_screenshot(driver, "job_name_not_found")
|
take_error_screenshot(driver, "job_name_not_found")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
job_id = job_url.split('/')[-1]
|
|
||||||
albums_overview_url = f"https://app.fotograf.de/config_jobs_photos/index/{job_id}"
|
albums_overview_url = f"https://app.fotograf.de/config_jobs_photos/index/{job_id}"
|
||||||
print(f"Navigiere zur Alben-Übersicht: {albums_overview_url}")
|
print(f"Navigiere zur Alben-Übersicht: {albums_overview_url}")
|
||||||
driver.get(albums_overview_url)
|
driver.get(albums_overview_url)
|
||||||
@@ -160,7 +164,6 @@ def process_full_job(driver, job_url):
|
|||||||
|
|
||||||
login_count_text = person_row.find_element(By.XPATH, SELECTORS["person_logins"]).text
|
login_count_text = person_row.find_element(By.XPATH, SELECTORS["person_logins"]).text
|
||||||
|
|
||||||
# --- HIER IST DIE GEÄNDERTE LOGIK ---
|
|
||||||
if int(login_count_text) <= 1:
|
if int(login_count_text) <= 1:
|
||||||
vorname = person_row.find_element(By.XPATH, SELECTORS["person_vorname"]).text
|
vorname = person_row.find_element(By.XPATH, SELECTORS["person_vorname"]).text
|
||||||
print(f" --> ERFOLG: '{vorname}' mit {login_count_text} Login(s) gefunden!")
|
print(f" --> ERFOLG: '{vorname}' mit {login_count_text} Login(s) gefunden!")
|
||||||
@@ -244,12 +247,18 @@ def main():
|
|||||||
credentials = get_profile_choice()
|
credentials = get_profile_choice()
|
||||||
if not credentials: return
|
if not credentials: return
|
||||||
|
|
||||||
job_url_raw = input("Bitte gib die URL des zu bearbeitenden Fotoauftrags ein (Einstellungs-Seite): ")
|
job_url_raw = input("Bitte gib eine beliebige URL des zu bearbeitenden Fotoauftrags ein: ")
|
||||||
job_url_cleaned = job_url_raw.replace("\x1b[200~", "").replace("\x1b[201~", "")
|
|
||||||
job_url = job_url_cleaned.strip()
|
# NEU: Robuste URL-Extraktion mit Regex, um Terminal-Steuerzeichen zu entfernen
|
||||||
|
match = re.search(r'https?://[^\s]+', job_url_raw)
|
||||||
|
if not match:
|
||||||
|
print("Keine gültige URL in der Eingabe gefunden.")
|
||||||
|
return
|
||||||
|
job_url = match.group(0)
|
||||||
|
|
||||||
if "fotograf.de/config_jobs_settings/index/" not in job_url:
|
# NEU: Flexible Überprüfung, die jede Job-Seite akzeptiert
|
||||||
print("Dies scheint keine gültige URL für die Auftragseinstellungen zu sein.")
|
if "fotograf.de/config_jobs_" not in job_url:
|
||||||
|
print("Dies scheint keine gültige URL für einen Fotoauftrag zu sein.")
|
||||||
return
|
return
|
||||||
|
|
||||||
driver = setup_driver()
|
driver = setup_driver()
|
||||||
|
|||||||
Reference in New Issue
Block a user