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"}
  1. Any response headers that might come from the proxy will be saved in response.headers

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.3.tar.gz (4.5 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.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scrapy-proxy-headers-0.1.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.13

File hashes

Hashes for scrapy-proxy-headers-0.1.3.tar.gz
Algorithm Hash digest
SHA256 33c3d5710c05187c1c88acdf7d4ab957e1c6b3b888350b38861b4cbb01e939dd
MD5 bf148631933a834c35f2b513b7c5e276
BLAKE2b-256 018848e16126490f2f5534f81ec0fa88950fdc96d78215402d623b6df25a623a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for scrapy_proxy_headers-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 553145cdfdfe52521167d253e752d38ae5a47590fef2fcd5728ae9b18150d42f
MD5 a6a028402d39bbee95997a43ddc59977
BLAKE2b-256 2d95f4a2fe68edc22d54297a4f4746b41ce4faf1a4976ae8f471b3257b912daf

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