Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/sig.py10# Module : louka11# Repository : https://git.spboucher.ai/lou-ka12# Created : 2026-08-0813# Last Modified : 2026-08-0814#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/sig.py : connecteur Société d'investissement Gilbert (immo-sig.ca)91# Résidences étudiantes en colocation à Québec (Université Laval, Cégep92# Sainte-Foy) : Le Sommet, Le Pavillon, La FAC, L'UNI. La page93# /residences-etudiantes/ (Elementor, rendue serveur) affiche pour chaque94# résidence le prix « à partir de » par chambre, l'adresse et une photo.95# Granularité = résidence (aucune unité détaillée publiée). Les fiches96# détaillées vivent sur residences-etudiantes.com, protégé par une97# vérification anti-bot reCAPTCHA -> immo-sig.ca est la source primaire ;98# le lien « DÉCOUVRIR » sert d'URL d'annonce pour l'utilisateur.99# -----------------------------------------------------------------------------100from __future__ import annotations101102import re103104from bs4 import BeautifulSoup105106from ..schema import Listing, strip_accents107from .base import BaseConnector108109BASE = "https://immo-sig.ca"110INDEX_URL = f"{BASE}/residences-etudiantes/"111112# variantes responsives WordPress (-300x200.jpg) à écarter113_VARIANT_IMG = re.compile(r"-\d{2,4}x\d{2,4}\.(?:jpe?g|png|webp)$", re.I)114115116def _slug(name: str) -> str:117 s = strip_accents((name or "").strip().lower())118 return re.sub(r"[^a-z0-9]+", "-", s).strip("-")119120121class SigConnector(BaseConnector):122 source_id = "sig"123 request_delay = 0.6124125 def fetch(self) -> list[Listing]:126 html = self.get(INDEX_URL).text127 soup = BeautifulSoup(html, "html.parser")128129 listings: list[Listing] = []130 seen: set[str] = set()131 # une colonne Elementor par résidence : photo + <h3> nom + texte132 # « COLOCATION ÉTUDIANTE / Unités de N chambres à partir de X$/mois /133 # adresse » + bouton DÉCOUVRIR134 for col in soup.select(".elementor-column"):135 h3 = col.select_one("h3.elementor-heading-title")136 text_w = col.select_one(".elementor-widget-text-editor")137 if not h3 or not text_w:138 continue139 name = re.sub(r"\s+", " ", h3.get_text(" ", strip=True))140 sid = _slug(name)141 if not name or sid in seen:142 continue143144 paras = [re.sub(r"[ \t]+", " ", p.get_text("\n", strip=True))145 for p in text_w.find_all("p")]146 tagline = paras[0] if paras else ""147 body = paras[1] if len(paras) > 1 else ""148 if "à partir de" not in body.lower():149 continue # pas un bloc résidence150 seen.add(sid)151152 # « Unités de 3 chambres à partir de 650$/mois\n2333 Chapdelaine »153 lines = [l.strip() for l in body.split("\n") if l.strip()]154 price_line = lines[0] if lines else ""155 address = lines[1] if len(lines) > 1 else ""156157 img = col.select_one("img[src]")158 images = []159 if img:160 src = (img.get("src") or "").strip()161 if src.startswith("http") and not _VARIANT_IMG.search(src):162 images.append(src)163164 link = col.select_one("a.elementor-button[href]")165 url = (link["href"] if link and166 str(link["href"]).startswith("http") else INDEX_URL)167168 # « meublées » n'est indiqué que pour L'UNI169 furnished = True if "meublé" in price_line.lower() else None170 m = re.search(r"unités?\s+de\s+([\d\s aà-]+chambres?)",171 price_line, re.I)172 desc = " — ".join(x for x in [173 tagline.capitalize(), price_line,174 "Fiche détaillée : " + url if url != INDEX_URL else ""] if x)175176 details = {"residence": name}177 listings.append(Listing(178 source=self.source_id,179 external_id=sid,180 url=url,181 title=f"{name} — Colocation étudiante",182 address=address,183 sector="", # non précisé à la source184 city="Québec",185 unit_type="Chambre", # colocation : location à la chambre186 price_label=price_line, # « ... à partir de 545$/mois »187 availability="", # aucune disponibilité affichée188 furnished=furnished,189 description=desc[:600],190 amenities=[t for t in [191 "Colocation étudiante",192 f"Unités de {m.group(1).strip()}" if m else ""] if t],193 details=details,194 images=images,195 ))196 return listings197