dealfront_enrichment.py aktualisiert
This commit is contained in:
@@ -195,42 +195,27 @@ class DealfrontScraper:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logger.info("Starte Dealfront Automatisierung - DEBUG-MODUS")
|
from selenium import webdriver
|
||||||
scraper = None
|
from selenium.webdriver.chrome.options import Options
|
||||||
try:
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
scraper = DealfrontScraper(driver, wait)
|
|
||||||
results = scraper.run("Facility Management")
|
|
||||||
if not scraper.driver:
|
|
||||||
raise Exception("WebDriver konnte nicht initialisiert werden.")
|
|
||||||
|
|
||||||
if not scraper.login_and_find_list(TempConfig.TARGET_SEARCH_NAME):
|
# 1) WebDriver konfigurieren
|
||||||
raise Exception("Der Prozess vom Login bis zum Laden der Liste ist fehlgeschlagen.")
|
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)
|
||||||
|
|
||||||
# In dieser Version gibt es keine handle_overlays Methode mehr
|
# 2) Explicit Wait erstellen
|
||||||
# scraper.handle_overlays()
|
wait = WebDriverWait(driver, 30)
|
||||||
|
|
||||||
companies = scraper.extract_current_page_results()
|
# 3) Scraper starten
|
||||||
if companies:
|
scraper = DealfrontScraper(driver, wait)
|
||||||
df = pd.DataFrame(companies)
|
results = scraper.run("Facility Management")
|
||||||
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.")
|
|
||||||
|
|
||||||
logger.info("Test erfolgreich abgeschlossen. Warte vor dem Schließen...")
|
# 4) Ergebnis ausgeben oder weiterverarbeiten
|
||||||
time.sleep(10)
|
for entry in results:
|
||||||
|
print(entry)
|
||||||
|
|
||||||
except Exception as e:
|
# 5) Aufräumen
|
||||||
logger.critical(f"Ein kritischer Fehler ist im Hauptprozess aufgetreten: {e}", exc_info=False)
|
driver.quit()
|
||||||
finally:
|
|
||||||
if scraper:
|
|
||||||
scraper.close()
|
|
||||||
|
|
||||||
logger.info("Dealfront Automatisierung beendet.")
|
|
||||||
Reference in New Issue
Block a user