feat(tradein-scripts): scrapers + probes + Phase C improvements #551
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#551
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/tradein-phase-c-script-improvements"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Что добавлено
Коммитим накопившиеся за день scrapers/probes — оперативные tools для локальной диагностики и residential-IP sweeps (когда VPS Beget IP заблокирован Avito/Yandex).
Sweep scripts (residential IP)
local-sweep-ekb.py— full ЕКБ Avito sweep через localhostlocal-sweep-ekb-cian.py— Cian ЕКБ vtorichka sweeplocal-sweep-ekb-yandex.py— Yandex Недвижимость ЕКБ sweepavito-playwright-sweep.py— Playwright-based Avito sweep, обходит Qrator JS challengebackfill-yandex-addresses-ekb.py— backfilllistings.address(street + house number) для active EKB yandex с short addressesProbes (diagnostics)
probe-avito-1anchor.py— 1 anchor × 1 page minimal dry-run (тест на bans)probe-db-counts.py— Avito listings count + recent insert rateprobe-db-leak-full.py— региональная утечка в Avito listings (3 угла: URL slug, address, geo)probe-db-region-leak.py/probe-db-url-leak.py— фокусированные leak checksprobe-migration-028.py/probe-migration-status.py— состояние SQL migrations 028..054probe-parser-region-filter.py— verify URL-filter работает в parserinspect-houses-html.py/inspect-search-html.py— Avito DOM analysis (после смены rendering)test-playwright.py— Playwright smoke testPhase C script (
backfill-house-imv.py) updatesapp.services.scrapers.avito_imvlogs в файл (envAVITO_LOG_PATHoverride). Сохраняет полную историю Avito API чисел для диагностики контракт-changes.Context
Эти tools использовались параллельно с roadmap из
[[Decision_TradeIn_DataQuality_8PR_Roadmap]]+ Phase C house-IMV backfill — большинство из них рождались как ad-hoc helpers, но многие пригодятся для будущей диагностики.Notes
New scripts: - avito-playwright-sweep.py — Playwright-based Avito sweep (bypasses Qrator) - backfill-yandex-addresses-ekb.py — fill street-only listings.address с house number - local-sweep-ekb-{cian,yandex,}.py — full ЕКБ sweep through residential IP - probe-* — quick diagnostics (region leak, migration status, parser filter, db counts) - inspect-{houses,search}-html.py — Avito DOM structure analysis - test-playwright.py — minimal Playwright smoke Phase C script updates (backfill-house-imv.py): - Pipe avito_imv module logs to avito-raw.log file (env AVITO_LOG_PATH override) - Clamp rooms=0 (studio) → 1 — Avito IMV API rejects rooms=0 with HTTP 400Deep Code Review — PR #551 verdict: APPROVE
Summary
70e45ce5e9Security (clean)
<PASS>placeholder in docstringsos.environ["DATABASE_URL"]everywhere (psycopg adapter swap for plainpostgresql://)avito-playwright-sweep.py:mainmasks password before logging (lines ~317-330).cian-cookies.jsongitignored; no cookie payloads committedCorrectness / idempotency
probe-db-*.pyare read-only — onlySELECT, zeroUPDATE/INSERT/DELETEbackfill-yandex-addresses-ekb.pyhas proper--dry-run+--limit+ skip when address unchangedprobe-migration-status.py:78callsconn.rollback()on per-check error — one failing check cannot poison subsequent onessave_listings()(per-page commit) — crash mid-sweep doesn't lose prior pagesbackfill-house-imv.pystudio clampmax(rooms_raw, 1)is safe: SQL filter hasWHERE rooms IS NOT NULL+ early-return atrow["rooms"] is None(line 154); no NoneType.int riskError handling per script (isolation)
SessionLocal(), own try/finally for DB sessionsexcept Exception as e: # noqa: BLE001+continuepattern across all sweeps — one failing page/anchor never aborts whole runRuntimeError("captcha")caught inphase_combos, breaks combo loop cleanlyPhase C
backfill-house-imv.pyreviewapp.services.scrapers.avito_imvlogger: idempotent because CLI is one-shot. Caveat: if someoneimports this script as a module, handler gets re-attached → multi-write to avito-raw.log. Not exercised in production path.AVITO_LOG_PATHenv override = good ergonomicsPattern consistency with prior sweep PRs (#533/#534/#535/#539)
_BACKEND_DIR / sys.path.insert(0, ...)+ weasyprint stub idiom as merged backfill scriptsfrom app.services.scrapers.* import ...pattern (post-stub import)argparse + asyncio.run(main())shapeLow-severity findings (non-blocking, do not require fix here)
avito-playwright-sweep.py:60-62injects_anchor_lat / _anchor_lon / _anchor_radius_mon theAvitoScraperinstance, butAvitoScraper._parse_htmldoes not consume those fields (onlyn1.pyreads them). Dead code, no harm — likely legacy from earlier iteration. Safe to drop in a follow-up cleanup.inspect-houses-html.py:55andinspect-search-html.py:31write to hard-coded/tmp/...paths — Linux/WSL only; will fail on Windows. These are local-only inspect scripts, mixed-OS dev tradeoff is fine..gitignorecovers.cian-cookies.jsonand*.cookies.jsonliteral, but.avito-cookies.jsonand.yandex-cookies.json(filenames already referenced in this PR) match neither pattern. Followup: extend gitignore totradein-mvp/scripts/.*-cookies.jsonso anyone running agit add .after generating local cookies can't accidentally commit them.inspect-houses-html.pydoes inlineimport remid-function (line ~83). Cosmetic.Cross-file impact (blast radius: zero on prod)
tradein-mvp/scripts/, not imported by backend app, not referenced by any cron/Celery/CI workflowbackfill-house-imv.py(operator-run CLI), with strictly additive behaviorPositive
probe-migration-status.pyis a clean diagnostic primitive worth keeping as deploy referencelocal-sweep-ekb.pyexponential backoff on 429 with retry-same-page (lines ~263-281) is a meaningful improvement overcontinue-only patternsRecommended next steps (optional, separate PR)
.gitignorewithtradein-mvp/scripts/.*-cookies.jsonglob_anchor_*injection inavito-playwright-sweep.pytradein/runbooks/referencing each script's purpose and usage flagsVerdict
Approve for merge. Ad-hoc operator scripts, zero blast radius on production. Security clean, idempotency correct, error handling isolated.