Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/evol.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/evol.py : connecteur EVOL Saint-Jean (evolstjean.com)91# Complexe locatif neuf au 270, rue de la Cabinetterie à92# Saint-Jean-sur-Richelieu (par Maître Carré). Site PHP statique rendu93# serveur : la page /les-unites.php affiche le prix plancher par typologie94# (« 3 ½ à partir de 1 575$ », « 2 ½ COMPLET »…) et les inclusions.95# Granularité : une annonce par typologie ; les typologies « COMPLET »96# (tout loué) sont ignorées.97# -----------------------------------------------------------------------------98from __future__ import annotations99100import re101102from bs4 import BeautifulSoup103104from ..schema import Listing, normalize_unit_type, parse_price105from .base import BaseConnector106107BASE = "https://evolstjean.com"108PAGE_URL = f"{BASE}/les-unites.php"109110ADDRESS = "270, rue de la Cabinetterie, Saint-Jean-sur-Richelieu"111CITY = "Saint-Jean-sur-Richelieu"112113# blocs typologie : « 3 ½ » suivi de « à partir de 1 575$ » ou « COMPLET »114TYPE_BLOCK_RE = re.compile(115 r"(\d)\s*½\s*(COMPLET|à partir de\s*[\d\s,]{3,9}\s*\$)", re.I)116IMG_RE = re.compile(r'(?:src|href)="((?:/|images/)[^"]+\.(?:jpe?g|png|webp))"', re.I)117PHONE_RE = re.compile(r"(\d{3})\s(\d{3})-(\d{4})")118119120class EvolConnector(BaseConnector):121 source_id = "evol"122 request_delay = 0.6123124 def fetch(self) -> list[Listing]:125 listings: list[Listing] = []126 try:127 html = self.get(PAGE_URL).text128 except Exception:129 return listings130 soup = BeautifulSoup(html, "html.parser")131 for tag in soup(["script", "style", "noscript"]):132 tag.decompose()133 text = re.sub(r"\s+", " ", soup.get_text(" ", strip=True))134135 # inclusions (liste de la section « Inclusions »)136 amenities: list[str] = []137 for kw, label in [138 (r"Cinq [ée]lectrom[ée]nagers|5 [ée]lectrom[ée]nagers",139 "5 électroménagers (frigo, cuisinière, lave-vaisselle, laveuse, sécheuse)"),140 (r"Eau chaude incluse", "Eau chaude incluse"),141 (r"Climatisation int[ée]gr[ée]e", "Climatisation"),142 (r"c[âa]blodistribution et Internet incluses",143 "Câble et Internet inclus"),144 (r"Comptoirs en quartz", "Comptoirs en quartz"),145 (r"Balcons?-terrasses? priv[ée]s", "Balcon-terrasse privé"),146 (r"[Aa]scenseur", "Ascenseur"),147 (r"[Ss]tationnement int[ée]rieur", "Stationnement intérieur ($)"),148 ]:149 if re.search(kw, text):150 amenities.append(label)151152 # photos du site (galerie de l'immeuble)153 images = [f"{BASE}/{u.lstrip('/')}"154 for u in dict.fromkeys(IMG_RE.findall(html))155 if not re.search(r"logo|favicon|icon|plan", u, re.I)][:15]156157 contact: dict = {}158 m = PHONE_RE.search(text)159 if m:160 contact["phone"] = f"{m.group(1)}-{m.group(2)}-{m.group(3)}"161162 for n, label in TYPE_BLOCK_RE.findall(text):163 if "COMPLET" in label.upper():164 continue # typologie entièrement louée en ce moment165 ut = normalize_unit_type(f"{n}½")166 price_label = re.sub(r"\s+", " ", label).strip()167 listings.append(Listing(168 source=self.source_id,169 external_id=f"evol-{n}.5",170 url=PAGE_URL,171 title=f"EVOL Saint-Jean — {ut}",172 address=ADDRESS,173 city=CITY,174 unit_type=ut,175 price=parse_price(price_label),176 price_label=price_label,177 description=("Complexe locatif neuf EVOL au cœur de "178 "Saint-Jean-sur-Richelieu : unités lumineuses "179 "aux finitions modernes (comptoirs en quartz, "180 "dosseret céramique), balcon-terrasse privé, "181 "généreuse fenestration."),182 amenities=list(amenities),183 details={"contact": dict(contact)} if contact else {},184 images=images,185 ))186 return listings187