SPB Git forge

spb/lou-ka

Public

Lou·Ka — tous les logements à louer du Québec, un seul endroit.

232commits 1branches 0releases
172.9 MBsize
maindefault branch
2 days agolast push
HTML 98.9% Python 0.6%

[ka2] fix connecteur lynk_olymbec: échec transitoire de /units journalisé comme échec (plus de passage « ok » à 0 annonce) + repli Scrapfly après Firecrawl

Simon-Pierre Boucher committed 1 mo ago (Aug 25, 2026) parent bfe6fe2

1 changed file +15 −7

modified louka/connectors/lynk_olymbec.py +15 −7
@@ -85,14 +85,21 @@ class LynkOlymbecConnector(BaseConnector):
85 85 self._detail_fetches = 0
86 86
87 87 def _get_page(self, url: str) -> str:
88 − """Essaie l'accès direct (en-têtes navigateur), sinon Firecrawl."""
88 + """Essaie l'accès direct (en-têtes navigateur), sinon Firecrawl,
89 + sinon Scrapfly (ASP) en dernier rideau."""
89 90 try:
90 91 resp = self.get(url, headers=BROWSER_HEADERS)
91 92 if "Just a moment" not in resp.text:
92 93 return resp.text
93 94 except Exception:
94 95 pass
95 − return self.get_rendered(url) # Cloudflare -> rendu Firecrawl
96 + try:
97 + html = self.get_rendered(url) # Cloudflare -> rendu Firecrawl
98 + if html and "Just a moment" not in html:
99 + return html
100 + except Exception:
101 + pass
102 + return self.get_scrapfly(url)
96 103
97 104 # -- sections d'icônes (ysi-icon-widget : libellé + sous-titre) -----------
98 105 @staticmethod
@@ -131,13 +138,14 @@ class LynkOlymbecConnector(BaseConnector):
131 138 return {"units": units, "images": images[:5]}
132 139
133 140 def fetch(self) -> list[Listing]:
141 + # un échec transitoire doit être journalisé comme ÉCHEC par ingest
142 + # (ok=0), pas comme un passage « ok » à 0 annonce qui marque tout
143 + # le parc manquant — on laisse donc l'exception remonter
134 144 listings: list[Listing] = []
135 − try:
136 − units_html = self._get_page(UNITS_URL)
137 − except Exception:
138 − return listings
145 + units_html = self._get_page(UNITS_URL)
139 146 if not units_html:
140 − return listings
147 + raise RuntimeError(
148 + "page /units inaccessible (direct, Firecrawl et Scrapfly)")
141 149 units_text = _strip_tags(units_html)
142 150 units_soup = BeautifulSoup(units_html, "html.parser")
143 151
144 152