Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : louka/connectors/fitz.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/fitz.py : connecteur Le Fitz (lefitz.ca) — condos locatifs,91# 3 tours au 77, route du Président-Kennedy à Lévis. WordPress + plugin92# maison « imedia-building-plans » : admin-ajax.php?action=get_unit_list&93# building_id=<term> renvoie le tableau complet des unités (no, type,94# étage, chambres, sdb, superficie, PRIX, disponibilité) ; les <tr>95# class="unit disabled" sont louées, class="unit" disponibles.96# Granularité : unité, avec prix.97# -----------------------------------------------------------------------------98from __future__ import annotations99100import re101102from bs4 import BeautifulSoup103104from ..schema import Listing, normalize_unit_type, parse_price105from .base import BaseConnector106107BASE = "https://lefitz.ca"108AJAX = f"{BASE}/wp-admin/admin-ajax.php"109110# tours (term_id -> nom) : data-term-id des boutons de /plan-unites/111BUILDINGS = [("44", "Tour 1"), ("14", "Tour 2"), ("10", "Tour 3")]112113ADDRESS = "77, route du Président-Kennedy, Lévis"114AMENITIES = ["Chauffé et éclairé", "Électroménagers inclus",115 "Internet haute vitesse inclus", "Gym et salle de yoga",116 "Piscine intérieure", "Terrasses et jardin communautaire"]117118119class FitzConnector(BaseConnector):120 source_id = "fitz"121 request_delay = 0.6122123 def fetch(self) -> list[Listing]:124 listings: list[Listing] = []125 seen: set[str] = set()126 for term_id, tower in BUILDINGS:127 try:128 html = self.get(AJAX, params={129 "action": "get_unit_list",130 "building_id": term_id}).text131 except Exception:132 continue133 soup = BeautifulSoup(html, "html.parser")134 for row in soup.select("tr.unit"):135 try:136 classes = row.get("class") or []137 if "disabled" in classes:138 continue # unité louée139 unit_no = (row.get("data-unit") or "").strip()140 if not unit_no or unit_no in seen:141 continue142 seen.add(unit_no)143144 def cell(name: str) -> str:145 el = row.select_one(f"td.unit__{name}")146 return el.get_text(" ", strip=True) if el else ""147148 unit_type = normalize_unit_type(cell("type"))149 price_label = cell("price")150 area = None151 m = re.search(r"([\d\s]+)\s*p\.?\s*c\.?", cell("area"))152 if m:153 area = float(m.group(1).replace(" ", "")154 .replace(" ", "").replace(" ", ""))155 bedrooms = bathrooms = None156 if cell("rooms").isdigit():157 bedrooms = float(cell("rooms"))158 if cell("bathrooms").replace(".", "").isdigit():159 bathrooms = float(cell("bathrooms"))160161 plan_img = row.get("data-image-desktop") or ""162 details: dict = {"floor": cell("floor") or163 row.get("data-floor", "")}164 if row.get("data-file"):165 details["floor_plan"] = row["data-file"]166 if row.get("data-balcony-area"):167 details["balcony_area"] = row["data-balcony-area"]168169 listings.append(Listing(170 source=self.source_id,171 external_id=unit_no,172 url=row.get("data-permalink")173 or f"{BASE}/plan-unites/",174 title=f"Unité {unit_no} — Le Fitz ({tower})",175 address=ADDRESS,176 city="Lévis",177 unit_type=unit_type,178 bedrooms=bedrooms,179 bathrooms=bathrooms,180 price=parse_price(price_label),181 price_label=price_label,182 availability=cell("availability"),183 area_sqft=area,184 description=f"Unité {unit_no} ({unit_type}), "185 f"étage {details['floor']}, {tower} du "186 "Fitz — condos locatifs avec vue à "187 "Lévis. Chauffage, éclairage, électro-"188 "ménagers et Internet inclus.",189 amenities=list(AMENITIES),190 details=details,191 images=[plan_img] if plan_img.startswith("http")192 else [],193 ))194 except Exception:195 continue196 return listings197