mirror of
https://gitlab.dit.htwk-leipzig.de/fsr-im/tools/flatscraper.git
synced 2025-07-15 11:08:48 +02:00
Fixed: Extract specific details (rooms, ...) in wogetra which caused a error if details is empty
This commit is contained in:
@ -3,6 +3,17 @@ from bs4 import BeautifulSoup
|
||||
|
||||
WOGETRA_URL = "https://www.wogetra.de/immobilien-vermarktungsart/miete/"
|
||||
|
||||
def find_property(details, property):
|
||||
prop = "N/A"
|
||||
if details:
|
||||
prop_row = details.find("div", class_=property)
|
||||
if prop_row:
|
||||
dd = prop_row.find("div", class_="dd")
|
||||
if dd:
|
||||
prop = dd.text.strip()
|
||||
return prop
|
||||
|
||||
|
||||
# Funktion: Scrape von Wogetra
|
||||
def scrape_wogetra():
|
||||
response = requests.get(WOGETRA_URL)
|
||||
@ -26,11 +37,12 @@ def scrape_wogetra():
|
||||
subtitle = subtitle_element.text.strip() if subtitle_element else "No Subtitle"
|
||||
link = link_element["href"] if link_element else "#"
|
||||
|
||||
rooms = details.find("div", class_="data-anzahl_zimmer").find("div", class_="dd").text.strip() if details else "N/A"
|
||||
size = details.find("div", class_="data-wohnflaeche").find("div", class_="dd").text.strip() if details else "N/A"
|
||||
rent = details.find("div", class_="data-nettokaltmiete").find("div", class_="dd").text.strip() if details else "N/A"
|
||||
warm_rent = details.find("div", class_="data-warmmiete").find("div", class_="dd").text.strip() if details else "N/A"
|
||||
availability = details.find("div", class_="data-verfuegbar_ab").find("div", class_="dd").text.strip() if details else "N/A"
|
||||
# Extract specific details
|
||||
rooms = find_property(details, "data-anzahl_zimmer")
|
||||
size = find_property(details, "data-wohnflaeche")
|
||||
rent = find_property(details, "data-nettokaltmiete")
|
||||
warm_rent = find_property(details, "data-warmmiete")
|
||||
availability = find_property(details, "data-verfuegbar_ab")
|
||||
|
||||
# Add property to list
|
||||
properties.append({
|
||||
|
Reference in New Issue
Block a user