dealfront_enrichment.py aktualisiert
This commit is contained in:
@@ -113,7 +113,7 @@ class DealfrontScraper:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def extract_current_page_results(self):
|
def extract_current_page_results(self):
|
||||||
# 1) Warte auf erste Ergebniszeile (bis zu 20 Sek.)
|
# 1) Warten bis mindestens eine Ergebnis-Zeile sichtbar ist
|
||||||
rows_locator = (By.CSS_SELECTOR, "table#t-result-table tbody tr[id]")
|
rows_locator = (By.CSS_SELECTOR, "table#t-result-table tbody tr[id]")
|
||||||
WebDriverWait(self.driver, 20).until(
|
WebDriverWait(self.driver, 20).until(
|
||||||
EC.visibility_of_element_located(rows_locator)
|
EC.visibility_of_element_located(rows_locator)
|
||||||
@@ -124,24 +124,24 @@ class DealfrontScraper:
|
|||||||
|
|
||||||
results = []
|
results = []
|
||||||
for i, row in enumerate(rows, 1):
|
for i, row in enumerate(rows, 1):
|
||||||
# 2) Name: erstes Profil-Link (<a href="/h/company/...">)
|
# Name: <div class="t-highlight-text t-highlight-text-product" title="...">
|
||||||
name_links = row.find_elements(
|
name_divs = row.find_elements(
|
||||||
By.XPATH,
|
By.CSS_SELECTOR,
|
||||||
".//td[contains(@class,'sticky-column')]//a[contains(@href,'/h/company/')]"
|
"div.t-highlight-text.t-highlight-text-product"
|
||||||
)
|
)
|
||||||
if not name_links:
|
if not name_divs:
|
||||||
logger.warning(f"Zeile {i}: Kein Name-Link gefunden. Überspringe.")
|
logger.warning(f"Zeile {i}: Kein Name-Element gefunden. Überspringe.")
|
||||||
continue
|
continue
|
||||||
name_elem = name_links[0]
|
name_elem = name_divs[0]
|
||||||
company_name = (name_elem.get_attribute("title") or name_elem.text).strip()
|
company_name = (name_elem.get_attribute("title") or name_elem.text).strip() # :contentReference[oaicite:0]{index=0}
|
||||||
|
|
||||||
# 3) Website: erster externer Link (target="_blank")
|
# Website: externer Link (target="_blank") in der dritten Spalte
|
||||||
ext_links = row.find_elements(By.XPATH, ".//a[@target='_blank']")
|
ext_links = row.find_elements(By.CSS_SELECTOR, "td:nth-of-type(3) a[target='_blank']")
|
||||||
if ext_links:
|
if ext_links:
|
||||||
href = ext_links[0].get_attribute("href")
|
href = ext_links[0].get_attribute("href")
|
||||||
website = href.replace("https://", "").replace("http://", "").rstrip("/")
|
website = href.replace("https://", "").replace("http://", "").rstrip("/")
|
||||||
else:
|
else:
|
||||||
# Fallback: Text der 3. <td>
|
# Fallback: reiner Text in td[3]
|
||||||
cells = row.find_elements(By.TAG_NAME, "td")
|
cells = row.find_elements(By.TAG_NAME, "td")
|
||||||
website = cells[2].text.strip() if len(cells) >= 3 else ""
|
website = cells[2].text.strip() if len(cells) >= 3 else ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user