Switch extraction fetcher to curl_cffi for Cloudflare-fronted sources#20
Merged
Conversation
Replaces httpx with curl_cffi in bioscancast/extraction/fetcher.py so the fetcher uses a browser TLS fingerprint (Chrome by default) and gets past Cloudflare/JA3 blocks that returned 401 on Reuters and intermittent 403s on CIDRAP during the docling eval. Streaming, 25 MB cap, magic-byte sniffing, and the never-raise contract are preserved. ExtractionConfig.user_agent is replaced with .impersonate; the impersonation profile sets a matching browser UA automatically. A pytest --live flag (registered in a new conftest.py) gates a live integration test against Reuters; suite stays hermetic by default. Closes #18. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
rapsoj
approved these changes
May 18, 2026
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.
Summary
curl_cffiinbioscancast/extraction/fetcher.pyso HTTP fetches use a browser TLS fingerprint (Chrome by default). This gets past Cloudflare/JA3-based blocks that returned HTTP 401 on Reuters and intermittent 403s on CIDRAP during the docling eval.ExtractionConfig.user_agentis replaced with.impersonate("chrome"default); the impersonation profile sets a matching browser UA automatically.response.close()since the streamingResponsein curl_cffi 0.15.0 isn't a context manager.tests/conftest.pyregisters alivepytest marker and a--liveCLI flag; live integration tests are skipped by default.https://www.reuters.com/to confirm the Cloudflare path actually works end-to-end.pytest --liveopt-in.Closes #18.
Test plan
pytest bioscancast/tests/— 179 passed, 1 skipped (live)pytest bioscancast/tests/test_extraction_fetcher.py --live— 15 passed (Reuters returns 200 + HTML, confirming the Cloudflare bypass)ExtractionConfig.user_agent(grep confirms only the newimpersonatefield is referenced)🤖 Generated with Claude Code