CloudScraper

The cloudscraper_proxy module provides proxy header support for CloudScraper.

Installation

First, install CloudScraper:

pip install cloudscraper

Then you can use the proxy header extension.

Usage

Using create_scraper()

The create_scraper() function is a drop-in replacement for cloudscraper.create_scraper() that adds proxy header capabilities:

from python_proxy_headers.cloudscraper_proxy import create_scraper

# Create a scraper with proxy headers
scraper = create_scraper(
    proxy_headers={'X-ProxyMesh-Country': 'US'},
    browser='chrome'
)

# Set proxy
scraper.proxies = {'https': 'http://user:pass@proxy.example.com:8080'}

# Make requests - proxy headers are automatically sent
response = scraper.get('https://httpbin.org/ip')
print(response.text)

Using ProxyCloudScraper Class

You can also use the ProxyCloudScraper class directly:

from python_proxy_headers.cloudscraper_proxy import ProxyCloudScraper

scraper = ProxyCloudScraper(
    proxy_headers={'X-Custom-Header': 'value'},
    enable_stealth=True
)

scraper.proxies = {'https': 'http://proxy.example.com:8080'}
response = scraper.get('https://example.com')

Updating Proxy Headers

You can update proxy headers after creating the scraper:

scraper = create_scraper(proxy_headers={'X-Header': 'initial'})

# Later, update headers
scraper.set_proxy_headers({'X-Header': 'updated', 'X-New': 'value'})

All CloudScraper Features Preserved

The extension preserves all CloudScraper features:

  • Cloudflare bypass (v1, v2, v3, Turnstile)

  • Browser emulation and user agent handling

  • Cipher suite customization

  • Proxy rotation

  • Stealth mode

  • Session management

scraper = create_scraper(
    proxy_headers={'X-ProxyMesh-Country': 'US'},
    browser='chrome',
    enable_stealth=True,
    stealth_options={
        'min_delay': 1.0,
        'max_delay': 3.0,
        'human_like_delays': True
    }
)

API Reference

create_scraper()

create_scraper(proxy_headers=None, sess=None, **kwargs)

Create a CloudScraper with proxy header support.

Parameters:
  • proxy_headers – Dict of headers to send to proxy servers

  • sess – Existing session to copy attributes from

  • kwargs – All other arguments passed to CloudScraper

Returns:

ProxyCloudScraper instance

ProxyCloudScraper Class

class ProxyCloudScraper(proxy_headers=None, **kwargs)

CloudScraper subclass with proxy header support.

Inherits all methods and attributes from cloudscraper.CloudScraper.

Parameters:
  • proxy_headers – Dict of headers to send to proxy servers

  • kwargs – All other arguments passed to CloudScraper

set_proxy_headers(proxy_headers)

Update the proxy headers and remount adapters.

Parameters:

proxy_headers – New proxy headers to use