Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/quartier_horizon.py10# Module : louka11# Repository : https://git.spboucher.ai/lou-ka12# Created : 2026-08-2513# Last Modified : 2026-08-2514#15# =============================================================================16# AUTHOR & PROFESSIONAL AFFILIATION17# =============================================================================18#19# Author : Simon-Pierre Boucher20# Position : Professor of Finance21# Institution : Université du Québec en Outaouais (UQO)22# Department : Département des sciences administratives23# Organization : SP Boucher24#25# Website : https://spboucher.ai26# Git : https://git.spboucher.ai27#28# =============================================================================29# OFFICIAL CONTACT DIRECTORY30# =============================================================================31#32# General : info@spboucher.ai33# Professional : contact@spboucher.ai34# Direct : simon@spboucher.ai35# Research : research@spboucher.ai36# Development : dev@spboucher.ai37# Support : support@spboucher.ai38# Security/Admin : admin@spboucher.ai39# Notifications : notifications@spboucher.ai40#41# Preferred Contact: contact@spboucher.ai42#43# =============================================================================44# COPYRIGHT & INTELLECTUAL PROPERTY45# =============================================================================46#47# Copyright (c) 202648# Simon-Pierre Boucher49#50# All rights reserved where applicable.51#52# This file is governed by the applicable project license,53# copyright notices, institutional agreements and relevant law.54#55# Unless expressly authorized by the applicable license or56# rights holder, copying, redistribution, sublicensing,57# publication and commercial exploitation are not permitted.58#59# Existing third-party rights and notices remain unaffected.60#61# =============================================================================62# CONFIDENTIALITY & SECURITY63# =============================================================================64#65# Classification : Public66# Distribution : Public repository; use is governed by the project license67# Security Contact : admin@spboucher.ai68#69# Access to this source does not independently grant permission70# to redistribute or disclose confidential materials.71#72# Do not embed credentials, private keys, access tokens,73# certificates or confidential personal information.74#75# =============================================================================76# LICENSE & MAINTENANCE77# =============================================================================78#79# License : None specified (no license file in this repository)80# Maintainer : Simon-Pierre Boucher81# Technical Contact: dev@spboucher.ai82#83# =============================================================================84# END OF SP BOUCHER SOURCE HEADER85# =============================================================================8687# -----------------------------------------------------------------------------88# Lou-Ka — Agrégateur de logements à louer (province de Québec)89# Auteur : Simon-Pierre Boucher — contact@spboucher.ai90# connectors/quartier_horizon.py : connecteur Quartier Horizon91# (quartierhorizon.com — Lévis, secteur Saint-Jean-Chrysostome : 1802, rue92# des Fines-Herbes). WordPress/Divi rendu serveur : la page /plans/ liste93# ~114 cartes <article class="ps-card"> dont TOUTES les données sont des94# attributs data-* (unité, bâtiment, étage, type 3½-5½, chambres,95# superficie, balcon, prix « à partir de », disponibilité, plan PDF, image96# du plan, état). États : disponible / attente / indisponible / a-venir —97# on n'ingère que « disponible » (comme aula exclut « attente »).98# -----------------------------------------------------------------------------99from __future__ import annotations100101import re102103from bs4 import BeautifulSoup104105from ..schema import Listing, normalize_unit_type106from .base import BaseConnector107108BASE = "https://quartierhorizon.com"109PLANS_URL = f"{BASE}/plans/"110111ADDRESS = "1802, rue des Fines-Herbes, Lévis, G6Z 2L1"112SECTOR = "Saint-Jean-Chrysostome"113CITY = "Lévis"114115PHONE_RE = re.compile(r"(\d{3})[\s.\-](\d{3})[\s.\-](\d{4})")116117118class QuartierHorizonConnector(BaseConnector):119 source_id = "quartier_horizon"120 request_delay = 0.6121122 def fetch(self) -> list[Listing]:123 listings: list[Listing] = []124 html = self.get(PLANS_URL).text125 soup = BeautifulSoup(html, "html.parser")126127 # contact du projet (affiché dans le pied de page / bandeau)128 details_common: dict = {}129 m = PHONE_RE.search(soup.get_text(" ", strip=True))130 if m:131 details_common["contact"] = {132 "phone": f"{m.group(1)}-{m.group(2)}-{m.group(3)}"}133134 for card in soup.select("article.ps-card"):135 try:136 if (card.get("data-etat") or "").strip() != "disponible":137 continue138 unit = (card.get("data-unite") or "").strip()139 bkey = (card.get("data-bkey") or "").strip()140 if not unit:141 continue142 ext_id = f"{bkey}-{unit}" if bkey else unit143144 unit_type = normalize_unit_type(card.get("data-type") or "")145 price = None146 montant = (card.get("data-montant") or "").replace(" ", "")147 if montant.isdigit() and 100 <= int(montant) <= 20000:148 price = float(montant)149 libre = (card.get("data-libre") or "").strip()150 phase = (card.get("data-phase") or "").strip()151 etage = (card.get("data-etagenom") or "").strip()152 bldg = (card.get("data-bldg") or "").strip()153154 bedrooms = None155 ch = (card.get("data-chambres") or "").strip()156 if ch.isdigit():157 bedrooms = float(ch)158 area = None159 sup = (card.get("data-superficie") or "").replace(" ", "")160 if sup.isdigit():161 area = float(sup)162163 amenities: list[str] = []164 if etage:165 amenities.append(f"Étage : {etage}")166 balcon = (card.get("data-balcon") or "").strip()167 if balcon.isdigit() and int(balcon) > 0:168 amenities.append(f"Balcon de {balcon} pi²")169170 details = dict(details_common)171 pdf = (card.get("data-pdf") or "").strip()172 if pdf:173 details["plan_pdf"] = pdf174 if phase:175 details["phase"] = phase176177 images: list[str] = []178 img = (card.get("data-image") or "").strip()179 if img.startswith("http"):180 images.append(img)181182 loc_bits = [b for b in183 (f"Bâtiment {bkey.upper() or bldg}", etage) if b]184 listings.append(Listing(185 source=self.source_id,186 external_id=ext_id,187 url=PLANS_URL,188 title=f"{unit_type} — unité {unit}, Quartier Horizon",189 address=ADDRESS,190 sector=SECTOR,191 city=CITY,192 unit_type=unit_type,193 bedrooms=bedrooms,194 price=price,195 price_label=(f"À partir de {montant} $ /mois"196 if price else ""),197 availability=(f"Libre : {libre}" if libre198 else "Disponible"),199 area_sqft=area,200 description=" · ".join(loc_bits),201 amenities=amenities,202 details=details,203 images=images,204 ))205 except Exception:206 continue207 return listings208