dealfront_enrichment.py aktualisiert
This commit is contained in:
@@ -195,42 +195,27 @@ class DealfrontScraper:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("Starte Dealfront Automatisierung - DEBUG-MODUS")
|
||||
scraper = None
|
||||
try:
|
||||
scraper = DealfrontScraper(driver, wait)
|
||||
results = scraper.run("Facility Management")
|
||||
if not scraper.driver:
|
||||
raise Exception("WebDriver konnte nicht initialisiert werden.")
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
if not scraper.login_and_find_list(TempConfig.TARGET_SEARCH_NAME):
|
||||
raise Exception("Der Prozess vom Login bis zum Laden der Liste ist fehlgeschlagen.")
|
||||
|
||||
# In dieser Version gibt es keine handle_overlays Methode mehr
|
||||
# scraper.handle_overlays()
|
||||
|
||||
companies = scraper.extract_current_page_results()
|
||||
if companies:
|
||||
df = pd.DataFrame(companies)
|
||||
pd.set_option('display.max_rows', None)
|
||||
pd.set_option('display.max_columns', None)
|
||||
pd.set_option('display.width', 1000)
|
||||
pd.set_option('display.max_colwidth', None)
|
||||
print("\n" + "="*80)
|
||||
print(" EXTRAHIERTE FIRMEN (ERSTE SEITE) ".center(80, "="))
|
||||
print("="*80)
|
||||
print(df.to_string(index=False))
|
||||
print("="*80 + "\n")
|
||||
else:
|
||||
logger.warning("Obwohl die Seite geladen wurde, konnten keine Firmen extrahiert werden.")
|
||||
# 1) WebDriver konfigurieren
|
||||
chrome_options = Options()
|
||||
chrome_options.add_argument("--headless") # headless mode
|
||||
chrome_options.add_argument("--no-sandbox") # für Docker
|
||||
chrome_options.add_argument("--disable-dev-shm-usage")
|
||||
driver = webdriver.Chrome(options=chrome_options)
|
||||
|
||||
logger.info("Test erfolgreich abgeschlossen. Warte vor dem Schließen...")
|
||||
time.sleep(10)
|
||||
# 2) Explicit Wait erstellen
|
||||
wait = WebDriverWait(driver, 30)
|
||||
|
||||
except Exception as e:
|
||||
logger.critical(f"Ein kritischer Fehler ist im Hauptprozess aufgetreten: {e}", exc_info=False)
|
||||
finally:
|
||||
if scraper:
|
||||
scraper.close()
|
||||
|
||||
logger.info("Dealfront Automatisierung beendet.")
|
||||
# 3) Scraper starten
|
||||
scraper = DealfrontScraper(driver, wait)
|
||||
results = scraper.run("Facility Management")
|
||||
|
||||
# 4) Ergebnis ausgeben oder weiterverarbeiten
|
||||
for entry in results:
|
||||
print(entry)
|
||||
|
||||
# 5) Aufräumen
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user