SPB Git

Repository Public

le_st_georges.py 6.8 KB 164 lines python

1# =============================================================================2#                  SP BOUCHER | SOFTWARE & RESEARCH3#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project          : Lou·Ka9# File             : louka/connectors/le_st_georges.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/le_st_georges.py : connecteur Le St-Georges (lestgeorges.ca)91#   11 295, 1re Avenue, Saint-Georges (Beauce, Chaudière-Appalaches) —92#   56 unités locatives sur 7 étages habités (3½ à 5½).93#   Même plateforme WordPress « do-selecteur-plans » que La Cour Appartements94#   et AULA Lévis : sélecteur SVG d'unités (polygones data-nom / data-etage /95#   data-type / data-prix, classes disponible / indisponible « Loué ») + REST96#   /wp-json/do-selecteur-plans/v1/unite (montant, superficies habitable et97#   balcon, plan PDF, libellé « Libre le … »). Tout le parsing et le cache BD98#   sont hérités de LaCourConnector ; seules changent les constantes du projet99#   et deux particularités du thème :100#     - le sélecteur est sur la PAGE D'ACCUEIL (PLANS_PATH vide) ;101#     - les photos du projet sont des PNG (le motif partagé ne retient que102#       jpg/webp) et les commodités sont des blocs `.sc_icons_item_title`103#       -> _site_images() et _project_amenities() sont redéfinies.104#   Les unités louées sont exclues (classe « indisponible », état REST).105# -----------------------------------------------------------------------------106from __future__ import annotations107108import re109110from bs4 import BeautifulSoup111112from .la_cour import LaCourConnector113114_IMG_RE = re.compile(115    r'https?://[^"\'\s\)]+/wp-content/uploads/[^"\'\s\)]+'116    r'\.(?:jpg|jpeg|png|webp)', re.I)117_SKIP_IMG = re.compile(118    r"logo|\blog[_-]|icon|favicon|badge|plan|selecteur"119    r"|-\d{2,4}x\d{2,4}\.", re.I)120121122class LeStGeorgesConnector(LaCourConnector):123    source_id = "le_st_georges"124125    BASE = "https://lestgeorges.ca"126    PLANS_PATH = ""              # le sélecteur d'unités est sur l'accueil127    NAME = "Le St-Georges"128    ADDRESS = "11 295, 1re Avenue, Saint-Georges, QC G5Y 2C2"129    SECTOR = "Centre-ville"130    CITY = "Saint-Georges"131    PHOTO_PAGES = ("",)          # photos publiées sur l'accueil132    AMENITY_PAGES = ("",)133134    # -- particularités du thème -----------------------------------------------135    def _site_images(self) -> list[str]:136        """Photos du projet : uploads jpg/png/webp de l'accueil (le thème137        publie des PNG), hors logos, badges et plans d'unités."""138        imgs: list[str] = []139        for page in self.PHOTO_PAGES:140            try:141                html = self.get(f"{self.BASE}/{page}").text142            except Exception:143                continue144            for u in dict.fromkeys(_IMG_RE.findall(html)):145                if not _SKIP_IMG.search(u) and u not in imgs:146                    imgs.append(u)147        return imgs[: self.max_images]148149    def _project_amenities(self) -> list[str]:150        """Commodités de l'immeuble : titres des blocs « Nos espaces, votre151        confort » (`.sc_icons_item_title`) de l'accueil."""152        items: list[str] = []153        for page in self.AMENITY_PAGES:154            try:155                html = self.get(f"{self.BASE}/{page}").text156            except Exception:157                continue158            soup = BeautifulSoup(html, "html.parser")159            for el in soup.select(".sc_icons_item_title"):160                t = re.sub(r"\s+", " ", el.get_text(" ", strip=True)).strip()161                if 3 <= len(t) <= 90 and t not in items:162                    items.append(t)163        return items[:30]164
Files main
Menu

Theme