Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/westwalk.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/westwalk.py : connecteur Westwalk DDO (westwalk.ca)91# Immeuble neuf au 12, rue Davignon, Dollard-des-Ormeaux (West-Island),92# à 10 min à pied du REM. WordPress/Elementor statique : la page93# /en/apartments-for-rent-dollard-des-ormeaux/ affiche un « image-box » par94# type d'unité (LOFT, 1-BEDROOM, 2-BEDROOMS, 3-BEDROOMS) avec soit un prix95# « Starting at $2,300 », soit « 100% rented » — seuls les types avec un96# prix réel sont annoncés (une annonce par type, id stable ww-ddo-<type>).97# Le site liste aussi Anjou (sans cartes) et Pointe-Claire (prix98# placeholders $X,XXX) : exclus. Commodités = titres h3 de la page.99# -----------------------------------------------------------------------------100from __future__ import annotations101102import re103104from bs4 import BeautifulSoup105106from ..schema import Listing, strip_accents107from .base import BaseConnector108109BASE = "https://westwalk.ca"110PAGE = f"{BASE}/en/apartments-for-rent-dollard-des-ormeaux/"111ADDRESS = "12, rue Davignon, Dollard-des-Ormeaux, QC H9B 0B6"112113# Libellé du type -> type d'unité QC114_TYPES = {115 "LOFT": "Loft",116 "1-BEDROOM": "3½",117 "2-BEDROOMS": "4½",118 "3-BEDROOMS": "5½",119}120_PRICE_RE = re.compile(r"\$\s*([\d][\d,\s]*\d|\d)")121_IMG_RE = re.compile(122 r'https://westwalk\.ca/wp-content/uploads/[^"\'\s]+?'123 r'\.(?:jpg|jpeg|png|webp)', re.I)124_SKIP_IMG = re.compile(r"logo|icon|favicon|bullet|map-|-\d{2,4}x\d{2,4}\.", re.I)125# h3 de la page qui ne sont PAS des commodités126_SKIP_H3 = re.compile(r"^(unit\s|follow|contact|westwalk)", re.I)127128129class WestwalkConnector(BaseConnector):130 source_id = "westwalk"131 request_delay = 0.6132 max_images = 20133134 def fetch(self) -> list[Listing]:135 html = self.get(PAGE).text136 soup = BeautifulSoup(html, "html.parser")137138 # galerie (photos du projet, sans logos/miniatures)139 images: list[str] = []140 for u in _IMG_RE.findall(html):141 if _SKIP_IMG.search(u):142 continue143 if u not in images:144 images.append(u)145 images = images[: self.max_images]146147 # commodités : titres h3 courts de la page (Elevator, Gym, Pool…)148 amenities: list[str] = []149 for h in soup.find_all("h3"):150 t = h.get_text(" ", strip=True)151 if t and len(t) < 60 and not _SKIP_H3.match(t):152 if t not in amenities:153 amenities.append(t)154 amenities = amenities[:25]155156 # description : méta de la page157 desc = ""158 meta = soup.find("meta", attrs={"name": "description"})159 if meta and meta.get("content"):160 desc = meta["content"].strip()[:600]161162 listings: list[Listing] = []163 for box in soup.select(".elementor-image-box-content"):164 t_el = box.select_one(".elementor-image-box-title")165 d_el = box.select_one(".elementor-image-box-description")166 if not (t_el and d_el):167 continue168 label = t_el.get_text(" ", strip=True).upper()169 if label not in _TYPES:170 continue171 price_txt = d_el.get_text(" ", strip=True)172 pm = _PRICE_RE.search(price_txt)173 if not pm:174 continue # « 100% rented » ou placeholder : exclu175 try:176 price = float(re.sub(r"[^\d]", "", pm.group(1)))177 except ValueError:178 continue179 if not (100 <= price <= 20000):180 continue181 slug = re.sub(r"[^a-z0-9]+", "-",182 strip_accents(label.lower())).strip("-")183 listings.append(Listing(184 source=self.source_id,185 external_id=f"ddo-{slug}",186 url=PAGE,187 title=f"Westwalk DDO — {label.title()}",188 address=ADDRESS,189 sector="Dollard-des-Ormeaux",190 city="Dollard-des-Ormeaux",191 unit_type=_TYPES[label],192 price=price,193 price_label=f"À partir de {int(price)} $/mois",194 availability=price_txt,195 description=desc,196 amenities=list(amenities),197 images=list(images),198 ))199 return listings200