Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/gcs_gabriel.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/gcs_gabriel.py : connecteur GCS Le Gabriel91# (gcs-legabriel.ca — 2860, rue Gabriel-Le Prévost, coin route de l'Église,92# plateau de Sainte-Foy, Québec : 121 condos locatifs sur 13 étages,93# promoteur GCS Développement immobilier). Site vitrine statique rendu94# serveur : les prix « UNITÉS À PARTIR DE » sont affichés PAR TYPE dans le95# tableau <table class="prenezmaintable"> du slider (Studios 1 241 $* …96# 5 1/2 2 848 $*). Une annonce par type d'unité — la granularité du site —97# avec les inclusions de la section « Inclusions » et les photos du slider.98# -----------------------------------------------------------------------------99from __future__ import annotations100101import re102103from bs4 import BeautifulSoup104105from ..schema import Listing, normalize_unit_type, parse_price106from .base import BaseConnector107108BASE = "https://gcs-legabriel.ca"109PAGE_URL = f"{BASE}/"110111ADDRESS = "2860, rue Gabriel-Le Prévost, Québec"112SECTOR = "Sainte-Foy"113CITY = "Québec"114LAT, LNG = 46.774762, -71.298140 # visite virtuelle Google Maps de la page115116# type affiché -> suffixe d'identifiant stable117TYPE_RE = re.compile(r"^(Studios?|\d\s*1/2\s*\+?)$", re.I)118IMG_RE = re.compile(r'(?:src|href)="((?:images/content/[^"]+|'119 r"images/[^\"]*slider[^\"]+)\.(?:jpe?g|png|webp))\"", re.I)120121122class GcsGabrielConnector(BaseConnector):123 source_id = "gcs_gabriel"124 request_delay = 0.6125126 def fetch(self) -> list[Listing]:127 listings: list[Listing] = []128 html = self.get(PAGE_URL).text129 soup = BeautifulSoup(html, "html.parser")130131 # photos du slider / des sections contenu132 images = [f"{BASE}/{u.lstrip('/')}" for u in133 dict.fromkeys(IMG_RE.findall(html))134 if not re.search(r"logo|icon|plan", u, re.I)][:20]135136 # inclusions de l'immeuble (accordéon « Inclusions » : div.acc-header137 # suivi d'un div.acc-content avec la liste <li>)138 amenities: list[str] = []139 for h in soup.select("div.acc-header"):140 if h.get_text(strip=True).lower().startswith("inclusion"):141 ul = h.find_next("ul")142 if ul:143 amenities = [li.get_text(" ", strip=True)144 for li in ul.find_all("li")145 if li.get_text(strip=True)][:20]146 break147148 # contact (lien tel: + courriel du pied de page)149 details_common: dict = {}150 contact: dict = {}151 m = re.search(r'href="tel:\+?1?(\d{10})"', html)152 if m:153 d10 = m.group(1)154 contact["phone"] = f"{d10[:3]}-{d10[3:6]}-{d10[6:]}"155 m = re.search(r'(?:href="mailto:)?([\w.\-]+@gcs[\w.\-]*\.com)', html)156 if m:157 contact["email"] = m.group(1).lower()158 if contact:159 details_common["contact"] = contact160161 # disponibilité affichée dans le slider (« Possibilité d'occupation162 # immédiate ! »)163 availability = ""164 am = re.search(r"Possibilit[ée] d[’']occupation\s*(?:<br\s*/?>)?\s*"165 r"immédiate", html, re.I)166 if am:167 availability = "Possibilité d'occupation immédiate"168169 # tableau « UNITÉS À PARTIR DE » : une rangée par type170 table = soup.select_one("table.prenezmaintable")171 if table is None:172 return listings173 for tr in table.find_all("tr"):174 try:175 tds = tr.find_all("td")176 if len(tds) < 2:177 continue178 type_txt = tds[0].get_text(strip=True)179 if not TYPE_RE.match(type_txt):180 continue181 price_txt = tds[1].get_text(strip=True)182 price = parse_price(price_txt)183 if price is None:184 continue185 plus = type_txt.rstrip("*").strip().endswith("+")186 unit_type = normalize_unit_type(187 type_txt.rstrip("+*s ") or type_txt)188189 extra = [tds[2].get_text(" ", strip=True)] \190 if len(tds) > 2 and tds[2].get_text(strip=True) else []191 ext_id = f"type-{unit_type.replace('½', '.5').lower()}" + \192 ("-plus" if plus else "")193 label = f"{unit_type}+" if plus else unit_type194195 listings.append(Listing(196 source=self.source_id,197 external_id=ext_id,198 url=PAGE_URL,199 title=f"{label} — Le Gabriel",200 address=ADDRESS,201 sector=SECTOR,202 city=CITY,203 unit_type=unit_type,204 price=price,205 price_label=f"À partir de {price_txt}".replace("*", ""),206 availability=availability,207 amenities=list(dict.fromkeys(extra + amenities)),208 details=dict(details_common),209 images=images,210 lat=LAT,211 lng=LNG,212 ))213 except Exception:214 continue215 return listings216