Home / Use cases / Downloads behind Cloudflare or a JS challenge
Protected downloadsDownloads behind Cloudflare or a JS challenge
Fetch a file from a site that serves a JavaScript challenge instead of the file to plain HTTP clients.
The problem
Some sites put a JavaScript interstitial in front of downloads. Plain wget and curl receive the challenge HTML, not the file — so your script quietly saves a few kilobytes of challenge page instead of the artifact you wanted.
How rewget solves it
- ▸rewget detects the block and, because the page needs JavaScript, escalates to stage 3.
- ▸Headless Chromium executes the challenge, then rewget exports the resulting session (cookies and headers).
- ▸The download completes through that session — from the same wget-style command you already ran.
- ▸For sites that only fingerprint TLS without a full JS challenge, the lighter stage 2 handles it with no browser at all.
$ rewget https://protected.example/model-weights.bin [stage 1: wget] 403 → escalating [stage 2: rquest/chrome131] 403 → escalating [stage 3: chromium] challenge solved → 200 OK
- ·Stage 3 only runs when the lighter stages cannot get through, so you are not paying browser startup on every download.
- ·rewget handles challenges a real browser would pass; it does not bypass logins or paywalls.
Questions
+ Why did plain wget save a tiny HTML file instead of my download?
That file is the JavaScript challenge page. wget cannot execute it, so it saves the interstitial. rewget's stage 3 runs the challenge in real Chromium and then fetches the actual file.
+ Is a browser launched for every download?
No. Stage 3 (Chromium) only starts when stages 1 and 2 both fail, and the working stage is then cached per domain.