Skip to content

v0.3.1

Latest

Choose a tag to compare

@jehrr jehrr released this 11 Nov 09:47
f73d4b5

Behaviour changes. (1) A run through a proxy now makes one pre-check
request before its first page request, in http_scraper.py and all three
browser engines. A proxy that answers HTTP 407 or 402 ends the run
with exit 5 and <out>.latest_attempt.meta.json (status: failed,
stop_reason: proxy_auth_failed / proxy_balance_exhausted) instead of
failing every retry. (2) Through a local proxy, the browser engines no
longer download
images, video/audio or fonts; --load-media (or
SLEEPNUMBER_LOAD_MEDIA=1) restores them. Runs without a proxy, over
--cdp-endpoint, and the HTML-only http_scraper.py fetch are otherwise
unchanged. (3) A run through a local proxy now stops at 10 MB of proxy
traffic
by default (--proxy-budget-mb, 0 = no cap), in every entry
point: it keeps its rows and exits 6 (5 with none) with
stop_reason: proxy_budget_exceeded, and it always writes
<out>.latest_attempt.meta.json.

(4) Exit codes that used to misname the cause. The site's own 404
exits 4 (was 3, "blocked"). selenium_scraper.py with a proxy that
has a login and password exits 2 before starting a browser (was 3,
blocked_blocked). puppeteer_scraper.py exits 5 with
stop_reason: browser_launch_failed when Chromium does not start (was a
traceback and 1). A page refused without a recognised vendor records
stop_reason: blocked, not blocked_blocked.

Added

  • proxy_meter.py: per-run proxy traffic meter and budget, in the three
    browser engines and http_scraper.py, only through a local proxy.
    Playwright sums request.sizes(); pyppeteer and Selenium count CDP
    Network.loadingFinished.encodedDataLength plus each request's own size;
    http_scraper.py counts every response hop and its request. Over budget,
    Playwright aborts new requests in a route, pyppeteer/Selenium block every
    URL over CDP, and every entry point stops before its next request; the
    --concurrency workers share one budget. New sidecar fields
    proxy_bytes, proxy_budget_bytes, proxy_budget_exceeded; a closing
    log line Proxy traffic: X.X MB of Y MB budget. --proxy-budget-mb and
    SLEEPNUMBER_PROXY_BUDGET_MB (in .env.example).

  • CI only: every canary run passes --proxy-budget-mb 10, its proxy
    traffic goes to the step summary, and the job fails with
    ::error::stopped: proxy budget 10 MB exceeded when a run hit the cap
    (.github/proxy_traffic.py).

  • Offline checks: the meter against known CDP and Playwright sizes,
    http_scraper.py through a byte-counting stub proxy, the sidecars and
    exit codes over budget, every engine driven past the budget, concurrent
    workers sharing it, the canary step and its summary script. An opt-in
    real-browser check (PROXY_METER_BROWSER=1) compares each driver's count
    with a stub proxy's.

  • proxy_check.py: the proxy pre-check (one CONNECT plus HEAD /robots.txt
    on www.sleepnumber.com, no third-party service), shared by
    http_scraper.py and the browser engines, plus media blocking for the
    three browser engines. The 407 message names SLEEPNUMBER_PROXY and says
    the gateway refused the credential (or the traffic balance is exhausted);
    a 402 says the proxy traffic/balance is exhausted. Neither prints the
    credential. A proxy that does not answer keeps the existing retry
    behaviour.

  • --load-media on the three browser engines, and SLEEPNUMBER_LOAD_MEDIA
    in .env.example.

  • Offline checks:

    • a stub proxy that answers 407/402/200 or nothing;
    • http_scraper.py and each engine driven to exit 5 on a 407, with no
      page request and no browser;
    • the attempt sidecar;
    • the Playwright route handler, the pyppeteer Fetch patterns and the
      Selenium blocked-URL list;
    • when each engine installs blocking.

Changed

  • CI only: the canary bills the SLEEPNUMBER_PROXY exit, so it now runs weekly
    (Mondays 11:23 UTC) instead of daily; a manual dispatch still runs it.

Fixed

  • The Docker image failed to build with playwright 1.65: its bundled node needs libatomic.so.1, which python:3.12-slim lacks, so playwright install exited 127. The Dockerfile now installs libatomic1 first.

  • The site's own 404 (for example --mode product --category i8) is reported as not found, exit 4, with a message naming the URL. CloudFront writes x-cache: Error from cloudfront on every 4xx/5xx, the site's 404 included, and that header alone used to make the page a block (exit 3) in http_scraper.py, Playwright and pyppeteer. It now counts as a refusal only when the body carries none of the site's assets. A 5xx the application rendered is retried rather than reported as not found.

  • selenium_scraper.py with a proxy that has a login and password now stops with exit 2 before starting a browser and says why (chromedriver cannot send a proxy password). It used to start Chrome without the credential, get the proxy's 407 and report exit 3 as though the site had refused. A credential the gateway itself rejects still ends with exit 5, proxy_auth_failed.

  • A page refused without a recognised vendor records stop_reason: blocked, not blocked_blocked, in every engine.

  • puppeteer_scraper.py: when Chromium does not start, the run ends with exit 5, stop_reason: browser_launch_failed and a pointer to --chromium-path, instead of a traceback and exit 1. pyppeteer's own exit hook, which could only raise "This event loop is already running", is no longer installed.

  • http_scraper.py accepts --concurrency like the browser engines. Every entry point now logs the same reason why it has no effect on this site, and runs sequentially. The Selenium and pyppeteer message no longer names a --mode transfers that does not exist here.

  • The proxy pre-check verifies the site's TLS certificate against certifi, as requests does. With Python from python.org on macOS (no system root certificates), every pre-check used to end with site: SSLCertVerificationError while the fetch itself worked.

  • Proxy budgets and traffic under 1 MB are logged with two significant figures: --proxy-budget-mb 0.05 reads 0.05 MB, not 0.1 MB, and 0.04 no longer reads 0.0 MB.

  • The proxy example in the README, .env.example and landing.md uses the login as the 2Captcha dashboard shows it and the eu.proxy.2captcha.com gateway. The bare proxy.2captcha.com is not a gateway (the connection times out), and a -zone-resi login was refused with HTTP 407. Pinning a US exit is shown as -zone-custom-region-us.

  • The README says to keep engine virtualenvs outside the clone: the offline checks skip only a directory named .venv, and third-party code in any other in-clone virtualenv fails them.

  • The pyppeteer and Selenium proxy meter counts only http:// / https:// requests and responses that came over the network. Chrome's own loads (the chrome:// new-tab page, data:, blob:), cache hits (requestServedFromCache, fromDiskCache, fromPrefetchCache, fromServiceWorker) and Chrome's error page count nothing. A sibling repo's Selenium run had counted about 2.8 MB of new-tab scripts while its proxy carried about 6 KB. The pyppeteer block sent once the budget is spent now reaches the page's own event loop even when the budget runs out on another thread.