update autoscraper, add another makellaar

This commit is contained in:
2026-04-03 16:09:38 +02:00
parent 17b35d1997
commit efd31686be
3 changed files with 145 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ Usage:
import re
import sys
import json
import httpx
from bs4 import BeautifulSoup, Tag
@@ -264,6 +265,31 @@ def cmd_details(url: str):
alt = img.get("alt", "")
print(f" {src} [{alt}]")
# JSON-LD
print("\n=== JSON-LD (schema.org) ===")
for tag in soup.select('script[type="application/ld+json"]'):
try:
ld = json.loads(tag.string)
offered = ld.get("itemOffered", {})
address = offered.get("address", {})
floor_size = offered.get("floorSize", {})
fields = {
"woningtype": offered.get("@type"),
"adres": address.get("streetAddress"),
"postcode": address.get("postalCode"),
"stad": address.get("addressLocality"),
"prijs": ld.get("price"),
"woonoppervlak": floor_size.get("value"),
"kamers": offered.get("numberOfRooms"),
"bouwjaar": offered.get("yearBuilt"),
"availability": ld.get("availability"),
"image": ld.get("image"),
}
for k, v in fields.items():
mark = "" if v is not None else ""
print(f" {mark} {k:<16} {v!r}")
except Exception as e:
print(f" parse fout: {e}")
# ---------------------------------------------------------------------------
# Entry point