Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/alias_appartements.py10# Module : louka11# Repository : https://git.spboucher.ai/lou-ka12# Created : 2026-08-0913# Last Modified : 2026-08-0914#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/alias_appartements.py : connecteur Alias Appartements91# (aliasappartements.com — rue des Mouettes, Jonquière, ville de Saguenay ;92# Groupe Boudreault). Projet locatif neuf UNIQUE de 80 unités 4½ livré en93# 4 phases (2023-2025). WordPress + Elementor + JetElements rendu serveur,94# page projet unique SANS fiches d'unités : le site publie le nombre95# d'unités (« 80 unités »), le type (« 4 1/2 »), le loyer plancher96# (« À partir de 1575$ »), l'adresse (h3 « Rue des Mouettes, Jonquière »),97# les caractéristiques (carrousel JetElements) et des photos — disponibilités98# par formulaire/contact. -> 1 annonce « catalogue » à granularité PROJET99# (précédent girs/immeubles_guillot), availability vide, rien d'inventé ;100# price via price_label (« à partir de », plus bas loyer).101# external_id stable : rue-des-mouettes.102# robots.txt Yoast ouvert (Disallow vide), sitemap public.103# -----------------------------------------------------------------------------104from __future__ import annotations105106import re107108from bs4 import BeautifulSoup109110from ..schema import Listing, normalize_unit_type111from .base import BaseConnector112113BASE = "https://www.aliasappartements.com"114115_UNITS_RE = re.compile(r"^\d+\s+unités$", re.I)116_TYPE_RE = re.compile(r"^([1-6])\s*(?:½|1/2)\s*$")117_PRICE_RE = re.compile(r"^à\s+partir\s+de\s+[\d\s]+\$", re.I)118_SKIP_IMG = re.compile(r"\.svg$|logo|icon|Group-\d+", re.I)119120121class AliasAppartementsConnector(BaseConnector):122 source_id = "alias_appartements"123 request_delay = 0.6124 max_images = 10125126 def fetch(self) -> list[Listing]:127 soup = BeautifulSoup(self.get(BASE + "/").text, "html.parser")128129 units_txt, unit_type, price_label, address = "", "", "", ""130 for h in soup.select(".elementor-heading-title"):131 t = re.sub(r"\s+", " ", h.get_text(" ", strip=True))132 if not t:133 continue134 if _UNITS_RE.match(t):135 units_txt = t136 elif _TYPE_RE.match(t):137 unit_type = normalize_unit_type(t)138 elif _PRICE_RE.match(t) and not price_label:139 price_label = t140 elif h.name == "h3" and re.search(r"(?i)mouettes", t):141 address = t142143 if not address and not units_txt:144 return [] # page méconnaissable : ne rien émettre145146 # caractéristiques : carrousel JetElements147 amenities: list[str] = []148 if units_txt:149 amenities.append(units_txt)150 for h5 in soup.select("h5.jet-carousel__item-title"):151 t = re.sub(r"\s+", " ", h5.get_text(" ", strip=True))152 if t and t not in amenities:153 amenities.append(t)154155 # paragraphes descriptifs (hors pied de page)156 paras: list[str] = []157 for p in soup.select(".elementor-widget-text-editor p"):158 t = re.sub(r"\s+", " ", p.get_text(" ", strip=True))159 if len(t) >= 100 and "©" not in t and len(paras) < 5:160 paras.append(t)161 description = "\n".join(paras)[:1600]162163 images: list[str] = []164 for img in soup.select("img[src*='/wp-content/uploads/']"):165 u = img["src"]166 if (u.startswith("http") and not _SKIP_IMG.search(u)167 and u not in images):168 images.append(u)169 if len(images) >= self.max_images:170 break171172 return [Listing(173 source=self.source_id,174 external_id="rue-des-mouettes",175 url=BASE + "/",176 title=f"Alias Appartements — {address or 'Rue des Mouettes, Jonquière'}",177 address=address or "Rue des Mouettes, Jonquière",178 sector="Jonquière",179 city="Saguenay",180 unit_type=unit_type,181 price=None, # déduit de price_label (« à partir de »)182 price_label=price_label,183 availability="", # disponibilités par formulaire/contact184 description=description,185 amenities=amenities[:30],186 images=images,187 )]188