
A Python module to bypass Cloudflare's anti-bot page.
Enhanced by Zied Boughdir
All features tested with 100% success rate for core functionality:
A Python module to bypass Cloudflare's anti-bot page (also known as "I'm Under Attack Mode", or IUAM), implemented with Requests. This enhanced version includes support for Cloudflare v2 challenges, proxy rotation, stealth mode, and more. Cloudflare changes their techniques periodically, so I will update this repo frequently.
This can be useful if you wish to scrape or crawl a website protected with Cloudflare. Cloudflare's anti-bot page currently just checks if the client supports Javascript, though they may add additional techniques in the future.
Due to Cloudflare continually changing and hardening their protection page, cloudscraper requires a JavaScript Engine/interpreter to solve Javascript challenges. This allows the script to easily impersonate a regular web browser without explicitly deobfuscating and parsing Cloudflare's Javascript.
For reference, this is the default message Cloudflare uses for these sorts of pages:
Checking your browser before accessing website.com.
This process is automatic. Your browser will redirect to your requested content shortly.
Please allow up to 5 seconds...
Any script using cloudscraper will sleep for ~5 seconds for the first visit to any site with Cloudflare anti-bots enabled, though no delay will occur after the first request.
Simply run pip install cloudscraper. The PyPI package is at https://pypi.org/project/cloudscraper/
pip install cloudscraper
Alternatively, clone this repository and run python setup.py install.
If you were previously using the original cloudscraper package, you can now use this enhanced version directly:
# Enhanced import
import cloudscraper # Enhanced version
The API remains compatible, so you only need to change the import statements in your code. All function calls and parameters work the same way.
The codebase has been streamlined to improve maintainability and reduce confusion:
cloudscraper modulecloudscraper moduleThis makes the codebase cleaner and easier to maintain while ensuring backward compatibility with existing code that uses the original API.
| Feature | Description | Status |
|---|---|---|
| π Executable Compatibility | Complete fix for PyInstaller, cx_Freeze, auto-py-to-exe conversion | β FIXED |
| π v3 JavaScript VM Challenges | Support for Cloudflare's latest JavaScript VM-based challenges | β NEW |
| π Turnstile Support | Support for Cloudflare's new Turnstile CAPTCHA replacement | β NEW |
| Modern Challenge Support | Enhanced support for v1, v2, v3, and Turnstile Cloudflare challenges | β Complete |
| Proxy Rotation | Built-in smart proxy rotation with multiple strategies | β Enhanced |
| Stealth Mode | Human-like behavior simulation to avoid detection | β Enhanced |
| Browser Emulation | Advanced browser fingerprinting for Chrome and Firefox | β Stable |
| JavaScript Handling | Better JS interpreter (js2py as default) for challenge solving | β Enhanced |
| Captcha Solvers | Support for multiple CAPTCHA solving services | β Stable |
python setup.py install will install the Python dependencies automatically. The javascript interpreters and/or engines you decide to use are the only things you need to install yourself, excluding js2py which is part of the requirements as the default.
We support the following Javascript interpreters/engines.
The simplest way to use cloudscraper is by calling create_scraper().
import cloudscraper