gendesign/tradein-mvp/backend/app/services
lekss361 5bf650c843 fix(tradein): route sweep shared-session (SERP+detail) через mobile proxy (#623)
Корень банов city-sweep: pipeline создаёт собственную shared AsyncSession и
присваивает её scraper._cffi, ПЕРЕЗАТИРАЯ проксированную сессию из
AvitoScraper.__aenter__ (#788). Через эту же сессию идёт и SERP, и detail-энричмент
(fetch_detail), и houses. Сессия создавалась без proxies → detail-страницы летели
с datacenter-IP → HTTP 429 → весь run mark_banned (scrape_runs id=9: «Avito detail
HTTP 429 …»). Единичный /admin/scrape работал, т.к. зовёт fetch_around напрямую
(проксированный _cffi из __aenter__), а не pipeline.

- scrape_pipeline.py: helper _avito_proxies() (из settings.avito_proxy_url) →
  proxies= в обе shared AsyncSession (run_avito_pipeline + run_avito_city_sweep).
  Пусто/нет env → прямое подключение (dev no-op). n1/yandex не трогаем (им прокси
  не нужен, не жжём мобильный трафик).
- test: _avito_proxies None без env / {http,https} при заданном URL.

Проверено: 18 passed (anti-bot + serp_date). ruff clean. Требует deploy (cron
city-sweep каждые 2ч на проде продолжит банить detail-429 до выката).

Refs #623, #788, #562.
2026-05-30 21:02:26 +03:00
..
exporters fix(pdf): brand-spoof + median=0 empty-state + SSRF + дисклеймер + sources (Refs #772) (#789) 2026-05-30 16:55:56 +00:00
matching feat(tradein): same-building матчинг аналогов по house_id (#6) 2026-05-28 13:55:51 +05:00
scrapers feat(scrapers/n1): извлекать floor/total_floors из ведущего N/M-токена (Refs #795) (#802) 2026-05-30 17:31:13 +00:00
__init__.py feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
account_quota.py fix(tradein): atomic conditional quota increment — close TOCTOU (#747) (#749) 2026-05-30 15:52:34 +00:00
brand.py feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
cache.py feat(tradein): Phase 3.2 — /api/v1/search endpoint + Redis cache (#479) 2026-05-23 14:44:22 +00:00
cian_session.py fix(cian): verify_session на curl_cffi impersonate — ban != cookies expired (Refs #768) (#785) 2026-05-30 16:40:54 +00:00
dadata.py feat(tradein): DaData /suggest tier в /suggest endpoint (PR Q2) 2026-05-27 19:08:58 +05:00
estimator.py fix(tradein): word-boundary street match + cian unescape robustness (Refs #769 A1+D) (#798) 2026-05-30 17:18:33 +00:00
geocoder.py feat(tradein): DaData /suggest tier в /suggest endpoint (PR Q2) 2026-05-27 19:08:58 +05:00
house_metadata.py feat(tradein): postgres_fdw live read of gendesign.cad_buildings (replaces snapshot) (#493) 2026-05-24 08:57:30 +00:00
image_sanitizer.py fix(tradein-photos): sanitize uploaded images via Pillow re-encode (#511) 2026-05-24 11:32:04 +00:00
scheduler.py fix(tradein): data-layer tail A2+B+C — trgm index, FDW options, matview refresh (Refs #769) (#804) 2026-05-30 17:40:54 +00:00
scrape_pipeline.py fix(tradein): route sweep shared-session (SERP+detail) через mobile proxy (#623) 2026-05-30 21:02:26 +03:00
scrape_runs.py fix(tradein/avito): anti-bot hardening — sleep + abort + shared session (#487) 2026-05-23 20:08:40 +00:00
scraper_settings.py feat(tradein): global scraper delay setting (applies across all scrapers) (#485) 2026-05-23 15:43:28 +00:00
search_query.py feat(tradein): Phase 3.2 — /api/v1/search endpoint + Redis cache (#479) 2026-05-23 14:44:22 +00:00