Skip to content

[autoscout24] fix swallowed page failures, pagination, dedupe and render cost - #183

Open
HishamM1 wants to merge 1 commit into
mainfrom
fix-autoscout24-scraper
Open

[autoscout24] fix swallowed page failures, pagination, dedupe and render cost#183
HishamM1 wants to merge 1 commit into
mainfrom
fix-autoscout24-scraper

Conversation

@HishamM1

Copy link
Copy Markdown
Contributor

Closes #182

concurrent_scrape yields errors instead of raising them, so a failed page used to land in the results as a page of zero listings. Guarding it positively is the core of this PR.

What changed in autoscout24.py:

  1. Guard on the success type - isinstance(response, ScrapeApiResponse) - not on an error class. The error classes are siblings, and an asp: True target most likely yields ScrapflyAspError, which a ScrapflyScrapeError check misses and then crashes on .selector. Same idiom as zoominfo.py:74.
  2. New change_page() replaces the string concat. It keeps repeated query keys, which AutoScout24 uses for multi-select filters (eq=1&eq=15) - dict(parse_qsl(...)) would drop all but the last one.
  3. Page cap is min(max_pages, numberOfPages). Listings are deduped by url. An empty payload logs a warning instead of passing as zero results.
  4. One sequential retry per page that came back empty. Under concurrency AutoScout24 intermittently bounces a page to the homepage; the same page fetched sequentially succeeds every time.
  5. render_js dropped. Identical __NEXT_DATA__ payload, 1 credit instead of 6.

Tests: offline test_page_url, flaky markers on both live tests plus pytest-rerunfailures in the dev group (the marker was a silent no-op without it), required: True on price and url, and >= 30 replaced by > 2 * len(first_page) with a unique-url assertion. The old count passed on 20 real listings plus 10 duplicates.

run.py takes detail urls from the listings it just scraped instead of three expired offers.

The workflow gets the new offline test folded into an existing runner rather than a new one, and -k is now quoted so a multi-name expression survives the shell.

Live validation: suite 3 passed in 49.26s. run.py -> 57 listings, 57 unique urls, 3/3 car details. The homepage bounce hit page 3 and one offer page during separate runs and the retry recovered both.

…der cost

concurrent_scrape yields errors instead of raising them and force-disables
upstream raising, so a failed page arrived as a normal response carrying an
empty __NEXT_DATA__ payload and was counted as a page of zero results.

- guard on the success type instead of one error class, the error classes are
  siblings and an asp target most likely yields ScrapflyAspError
- add change_page() so a url that already carries ?page= is not given a second
  one, keeping repeated query keys used by the multi select filters
- cap pages at numberOfPages, dedupe listings by url, warn on empty payloads
- retry a page that came back empty once, sequentially, since AutoScout24
  intermittently bounces a page to the homepage under concurrency
- drop render_js, the payload is server rendered and costs 1 credit not 6
- take run.py detail urls from the listings instead of expired offers
- add an offline test for change_page, flaky markers with pytest-rerunfailures,
  required price and url in the schemas, and a page relative count assertion
@HishamM1 HishamM1 self-assigned this Aug 20, 2026
@HishamM1
HishamM1 requested a review from mazen-r August 20, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[autoscout24] scraper silently drops failed pages and reports success

1 participant