Skip to content

feat(scraping): add --curl-file to replay browser headers - #13

Open
spencerhilz wants to merge 1 commit into
franckferman:stablefrom
spencerhilz:feat/curl-file
Open

spencerhilz wants to merge 1 commit into
franckferman:stablefrom
spencerhilz:feat/curl-file

Conversation

@spencerhilz

Copy link
Copy Markdown

Full disclosure, this code was written by Claude. However, it successfully addressed my use case, so I figured I could at least share it here.

Bot-detection services often check the full request header set, not just the User-Agent, so --user-agent alone is not enough to get through. --curl-file reads a request copied with the browser dev tools "Copy as cURL" (bash or cmd flavour, or '-' for stdin) and replays its headers and cookies on every scraping request.

  • Parses -H/--header, -b/--cookie, -A/--user-agent, -e/--referer, with support for $'...' quoting and Chrome's Windows cmd escaping.
  • Drops headers that would break urllib or only fit the original request (Host, Content-Length, Accept-Encoding, conditional headers, ...).
  • Cookies and auth/CSRF headers are only sent to the host the command was copied from, including across redirects (--follow-extern safe).
  • --user-agent, if given, overrides the imported User-Agent.
  • Geocoding requests to Nominatim are unaffected.

Bot-detection services often check the full request header set, not just
the User-Agent, so --user-agent alone is not enough to get through.
--curl-file reads a request copied with the browser dev tools
"Copy as cURL" (bash or cmd flavour, or '-' for stdin) and replays its
headers and cookies on every scraping request.

- Parses -H/--header, -b/--cookie, -A/--user-agent, -e/--referer, with
  support for $'...' quoting and Chrome's Windows cmd escaping.
- Drops headers that would break urllib or only fit the original request
  (Host, Content-Length, Accept-Encoding, conditional headers, ...).
- Cookies and auth/CSRF headers are only sent to the host the command was
  copied from, including across redirects (--follow-extern safe).
- --user-agent, if given, overrides the imported User-Agent.
- Geocoding requests to Nominatim are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HNXpLGLxWEMVQ15XAvffbT
@spencerhilz spencerhilz closed this Oct 3, 2026
@spencerhilz spencerhilz reopened this Oct 3, 2026

This branch has not been deployed

No deployments
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.

1 participant