SPB Git

Repository Public

agence_sherbrooke.py 5.8 KB 138 lines python

1# =============================================================================2#                  SP BOUCHER | SOFTWARE & RESEARCH3#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project          : Lou·Ka9# File             : louka/connectors/agence_sherbrooke.py10# Module           : louka11# Repository       : https://git.spboucher.ai/lou-ka12# Created          : 2026-08-0913# Last Modified    : 2026-08-3014#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/agence_sherbrooke.py : connecteur Agence de location Sherbrooke91#   (agencedelocationsherbrooke.com) — le portail d'annonces du groupe92#   Prestiplex (prestiplex.com n'affiche plus d'inventaire : son sitemap93#   property ne contient qu'une fiche de test). Sherbrooke, East Angus, Magog.94#   Même plateforme WordPress + thème Houzez que Gestion Dynamic : parsing95#   hérité de DynamicConnector. Particularités du site :96#     - la PAGE D'ACCUEIL est la page d'annonces (LIST_PATH = "/") ;97#     - la disponibilité est l'étiquette /label/ de la carte98#       (« Libre maintenant », « Juillet »…) ;99#     - l'adresse complète (Nominatim) est déjà sur la carte100#       (address.item-address) — ville/secteur en sont déduits.101# -----------------------------------------------------------------------------102from __future__ import annotations103104import time105106from ..schema import Listing107from .dynamic import DynamicConnector108109110class AgenceSherbrookeConnector(DynamicConnector):111    source_id = "agence_sherbrooke"112113    BASE = "https://agencedelocationsherbrooke.com"114    LIST_PATH = "/"115    CITY_DEFAULT = "Sherbrooke"116    max_pages = 6117118    def fetch(self) -> list[Listing]:119        # Un raté transitoire de la page liste (vu 2026-08-30 ~03:42)120        # produisait un faux « 0 trouvé ok » (médiane 12) : le fetch hérité121        # avale les exceptions et retourne [] sans cartes. Retry court122        # (backoff 5/10 s), puis erreur franche plutôt qu'un zéro silencieux.123        for attempt in range(3):124            listings = super().fetch()125            if listings:126                return listings127            if attempt < 2:128                time.sleep(5 * (attempt + 1))129        raise RuntimeError(130            "0 annonce extraite de la page liste après 3 essais")131132    # -- crochets par site --------------------------------------------------------133    def _card_availability(self, card, title: str) -> str:134        """Agence : étiquette /label/ de la carte (« Libre maintenant »,135        « Juillet »…) — le lien /status/ porte plutôt le secteur."""136        label_el = card.select_one("a[href*='/label/']")137        return label_el.get_text(" ", strip=True) if label_el else ""138
Files main
Menu

Theme