feat(scraping): add --curl-file to replay browser headers - #13
Open
spencerhilz wants to merge 1 commit into
Open
spencerhilz wants to merge 1 commit into
spencerhilz wants to merge 1 commit into
Conversation
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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.