dealfront_enrichment.py aktualisiert
This commit is contained in:
@@ -61,17 +61,25 @@ class DealfrontScraper:
|
||||
logger.error(f"Fehler beim Parsen der Credentials-Datei: '{DEALFRONT_CREDENTIALS_FILE}'")
|
||||
return None, None
|
||||
|
||||
def _save_error_screenshot(self):
|
||||
"""Speichert einen Screenshot im Fehlerfall in das definierte OUTPUT_DIR mit Zeitstempel."""
|
||||
def _save_debug_artifacts(self):
|
||||
"""Speichert einen Screenshot UND den HTML-Quellcode im Fehlerfall."""
|
||||
try:
|
||||
# Sicherstellen, dass der Ausgabeordner im Container existiert
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
timestamp = time.strftime("%Y%m%d-%H%M%S")
|
||||
filepath = os.path.join(OUTPUT_DIR, f"login_error_{timestamp}.png")
|
||||
self.driver.save_screenshot(filepath)
|
||||
logger.error(f"Screenshot '{filepath}' wurde für die Analyse gespeichert.")
|
||||
except Exception as e_ss:
|
||||
logger.error(f"Konnte Screenshot nicht speichern: {e_ss}")
|
||||
|
||||
# 1. Screenshot speichern
|
||||
screenshot_filepath = os.path.join(OUTPUT_DIR, f"error_{timestamp}.png")
|
||||
self.driver.save_screenshot(screenshot_filepath)
|
||||
logger.error(f"Screenshot '{screenshot_filepath}' wurde für die Analyse gespeichert.")
|
||||
|
||||
# 2. HTML-Quellcode speichern
|
||||
html_filepath = os.path.join(OUTPUT_DIR, f"error_{timestamp}.html")
|
||||
with open(html_filepath, "w", encoding="utf-8") as f:
|
||||
f.write(self.driver.page_source)
|
||||
logger.error(f"HTML-Quellcode '{html_filepath}' wurde für die Analyse gespeichert.")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Konnte Debug-Artefakte nicht speichern: {e}")
|
||||
|
||||
def login(self):
|
||||
"""
|
||||
@@ -125,7 +133,7 @@ class DealfrontScraper:
|
||||
|
||||
except Exception as e:
|
||||
logger.critical(f"Ein Fehler ist während des Logins aufgetreten: {type(e).__name__}", exc_info=True)
|
||||
self._save_error_screenshot()
|
||||
self._save_debug_artifacts()
|
||||
return False
|
||||
|
||||
def close(self):
|
||||
|
||||
Reference in New Issue
Block a user