Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/viventi.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/viventi.py : connecteur Complexe Viventi Laval (viventilaval.com)91# Immeuble unique pour 45/50 ans et plus au 1100, boul. Vanier (secteur92# Saint-Vincent-de-Paul, Laval). WordPress/Elementor rendu serveur : la page93# /nos-unites/ affiche une section par TYPOLOGIE (3½, 4½) avec prix94# « À partir de X$/mois » et liste d'inclusions. Granularité TYPOLOGIE,95# pas de disponibilité par unité.96# -----------------------------------------------------------------------------97from __future__ import annotations9899import re100101from bs4 import BeautifulSoup102103from ..schema import Listing, normalize_unit_type104from .base import BaseConnector105106BASE = "https://viventilaval.com"107PAGE_URL = f"{BASE}/nos-unites/"108109ADDRESS = "1100, boul. Vanier"110CITY = "Laval"111SECTOR = "Saint-Vincent-de-Paul"112113TYPE_RE = re.compile(r"^\d\s*(?:1/2|½)$")114PRICE_RE = re.compile(r"À partir de\s*([\d\s ,]+)\s*\$\s*/\s*mois", re.I)115IMG_RE = re.compile(116 r"https://viventilaval\.com/wp-content/uploads/[^\"'\s\\)]+?"117 r"\.(?:jpg|jpeg|png|webp)", re.I)118119120class ViventiConnector(BaseConnector):121 source_id = "viventi"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")131132 # photos communes de l'immeuble (les sections typologie n'ont pas de133 # galerie propre) — on écarte logos/favicons et miniatures redimensionnées134 images = [u for u in dict.fromkeys(IMG_RE.findall(html))135 if not re.search(r"logo|favicon|icon|-\d+x\d+\.", u, re.I)][:20]136137 # une section par typologie : <h2>3 1/2</h2> suivi d'un widget texte138 # avec « À partir de X$/mois » + <ul> d'inclusions139 for heading in soup.select(".elementor-heading-title"):140 label = heading.get_text(" ", strip=True)141 if not TYPE_RE.match(label):142 continue143 unit_type = normalize_unit_type(label)144 container = heading.find_parent(145 "div", class_="elementor-widget-heading")146 price_label, description, amenities = "", "", []147 node = container148 # widgets suivants de la même section (jusqu'à la prochaine typologie)149 while node is not None:150 node = node.find_next_sibling("div")151 if node is None:152 break153 text = node.get_text(" ", strip=True)154 if TYPE_RE.match(text):155 break156 m = PRICE_RE.search(text)157 if m and not price_label:158 price_label = ("À partir de "159 + re.sub(r"[\s ]", "", m.group(1))160 + " $/mois")161 for li in node.select("li"):162 item = li.get_text(" ", strip=True)163 if item and item not in amenities:164 amenities.append(item)165 if not description:166 for p in node.select("p"):167 t = p.get_text(" ", strip=True)168 if len(t) > 60 and "partir de" not in t.lower():169 description = t170 break171 if not price_label:172 continue173 ext_id = f"vanier-{unit_type.replace('½', '.5')}"174 listings.append(Listing(175 source=self.source_id,176 external_id=ext_id,177 url=PAGE_URL,178 title=f"{unit_type} — Complexe Viventi Laval (50 ans et plus)",179 address=ADDRESS,180 sector=SECTOR,181 city=CITY,182 unit_type=unit_type,183 price_label=price_label,184 description=description[:1500],185 amenities=amenities,186 details={"clientele": "50 ans et plus"},187 images=images,188 ))189 return listings190