Skip to main content

Add custom proxy headers to HTTPS requests in Scrapy

Project description

The scrapy-proxy-headers package is designed for adding proxy headers to HTTPS requests.

In normal usage, custom headers put in request.headers cannot be read by a proxy when you make a HTTPS request, because the headers are encrypted and passed through the proxy tunnel, along with the rest of the request body. You can read more about this at Proxy Server Requests over HTTPS.

Because Scrapy does not have a good way to pass custom headers to a proxy when you make HTTPS requests, we at ProxyMesh made this extension to support our customers that use Scrapy and want to use custom headers to control our proxy behavior. But this extension can work for any custom headers through a proxy.

To use this extension, do the following:

  1. pip install scrapy_proxy_headers
  2. In your Scrapy settings.py, add the following code:
DOWNLOAD_HANDLERS = {
  "https": "scrapy_proxy_headers.HTTP11ProxyDownloadHandler"
}
  1. When you want make a request with a custom proxy header, instead of using request.headers, use request.meta["proxy_headers"] like this:
request.meta["proxy_headers"] = {"X-ProxyMesh-Country": "US"}

Currently this package does not yet support reading custom response headers from the proxy, but that feature is coming soon.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrapy_proxy_headers-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrapy_proxy_headers-0.1.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file scrapy_proxy_headers-0.1.2.tar.gz.

File metadata

  • Download URL: scrapy_proxy_headers-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.10

File hashes

Hashes for scrapy_proxy_headers-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2eedf3199172649bfafd67bae12286090922535e5346ff77719911123e3489f5
MD5 5a0850360847e7ba271be2d80c1efb9e
BLAKE2b-256 77ec41a2408877cbbdf884e2d472b56d5167f0279e86f6132a6dc7f9d65c685d

See more details on using hashes here.

File details

Details for the file scrapy_proxy_headers-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_proxy_headers-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 856548ac92b0e4f732e4bbc0beedd241cc727bdee1e27c1b9b8b58b1a11fa05b
MD5 74845be6e9d3c34bae13e73bf2450e87
BLAKE2b-256 7060266db30b981a30aabb63a8ad08b0414eb166d98fc8dbdd63e94481680cf0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page