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.1.tar.gz (4.1 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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file scrapy-proxy-headers-0.1.1.tar.gz.

File metadata

  • Download URL: scrapy-proxy-headers-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 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.1.tar.gz
Algorithm Hash digest
SHA256 3285a5d711362c265d56b9e1c9b5c513f29bbbf823c0dc54d6a205948fd23f63
MD5 e0b178454ffd7b7533aeec169b21c4e0
BLAKE2b-256 413cf18fd9fa9df6988177002aad49d7b8c3c42e78c4070fef6a05186c48049c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for scrapy_proxy_headers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ca12852958e6a267bb09b44f40b970190e578873239390f7e4a24688f14cf20
MD5 2e520fc0500f447b2d72be8b22911692
BLAKE2b-256 98c199198eabc6e8580c4e7b8915d72bacc1c99ce0b045ae8438f7ae79499698

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