feat: bypass Cloudflare bot protection with curl_cffi - #2
Merged
Conversation
nille
force-pushed
the
feat/cloudflare-bypass
branch
2 times, most recently
from
April 18, 2026 09:06
d2eca2c to
338e063
Compare
- curl_cffi Chrome TLS impersonation bypasses Cloudflare bot challenges - Falls back to stdlib urllib when curl_cffi is not installed - HTTP 403 retried with exponential backoff - Z suffix date parsing fixed for Python 3.10 - CI: ruff lint + format, mypy type checking, tests on 3.10/3.12/3.14 - README badges: CI, Python version, Ruff, MIT license - pyproject.toml with ruff and mypy configuration - Ruff-formatted codebase, all lint issues fixed
nille
force-pushed
the
feat/cloudflare-bypass
branch
from
April 18, 2026 09:10
338e063 to
5f6cbe3
Compare
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_cffiis installed (pip install curl_cffi), API requests use Chrome TLS fingerprint impersonation to bypass Cloudflare JavaScript challenges that block standard HTTP clients with HTTP 403urllibwhencurl_cffiis not installed — zero required dependencies preservedBackground
Boligportal.dk recently enabled Cloudflare bot management, which detects non-browser TLS fingerprints and issues JavaScript challenges. Standard
urllibrequests get a 403 withcf-mitigated: challengeheader.curl_cffiimpersonates Chrome's TLS handshake, which Cloudflare accepts.Changes
boligwatch.py: Split_api_requestinto_api_request_cffiand_api_request_urllibbackends, with auto-detection dispatch. Extracted_backoff_delayhelper. AddedOrigin/Refererheaders for cffi backend.test_boligwatch.py: Added tests for dispatch logic, backoff helper, and 403 retry behavior (60 total, up from 55)CHANGELOG.md: Documented new feature and 403 retry fixREADME.md: Added Cloudflare bypass section, updated requirements and installationTest plan
curl_cffiinstalled — verify API returns 200curl_cffi— verify fallback to urllib--peekmode works end-to-end with Cloudflare active