SPB Git forge

spb/lou-ka

Public

Lou·Ka — tous les logements à louer du Québec, un seul endroit.

232commits 1branches 0releases
172.9 MBsize
maindefault branch
2 days agolast push
HTML 98.9% Python 0.6%
2.0 KB · 48 lines python
Raw Blame History
1# -----------------------------------------------------------------------------2# Lou-Ka — Agrégateur de logements à louer (province de Québec)3# Auteur : Simon-Pierre Boucher — contact@spboucher.ai4# connectors/vallem.py : connecteur Vallem (vallem.ca — condos locatifs +5#   marché d'alimentation au 4605, chemin du Crépuscule, quartier Lumicité,6#   Saint-Mathieu-de-Beloeil, à l'entrée de la vallée du Richelieu).7#   Le site statique n'affiche aucun prix : la page /plans est un simple8#   iframe Planpoint (app.planpoint.io/otium/vallem) — on interroge l'API9#   JSON publique via le helper _planpoint.py. Granularité = UNITÉ (prix,10#   pi², chambres, étage, plans). Le projet Planpoint ne publie pas11#   d'adresse -> adresse civique fixée ici (Google Maps du site officiel).12# -----------------------------------------------------------------------------13from __future__ import annotations1415from ..schema import Listing16from ._planpoint import planpoint_projects, unit_listing17from .base import BaseConnector1819PAGE_URL = "https://vallem.ca/plans/"20NAMESPACE = "otium"21HOST_NAME = "vallem"22ADDRESS = "4605, chemin du Crépuscule"23CITY = "Saint-Mathieu-de-Beloeil"242526class VallemConnector(BaseConnector):27    source_id = "vallem"28    request_delay = 0.82930    def fetch(self) -> list[Listing]:31        try:32            projects = planpoint_projects(self, "projects",33                                          NAMESPACE, HOST_NAME)34        except Exception:35            return []36        listings: list[Listing] = []37        for project in projects:38            for floor in project.get("floors") or []:39                for unit in floor.get("units") or []:40                    lst = unit_listing(self.source_id, project, floor, unit,41                                       page_url=PAGE_URL, default_city=CITY)42                    if lst is None:43                        continue44                    if not lst.address:      # projet Planpoint sans adresse45                        lst.address = ADDRESS46                    listings.append(lst)47        return listings48