Skip to main content

Scrapy downloader middleware for ProxyHat residential proxies — rotation, geo-targeting, sticky sessions.

Project description

scrapy-proxyhat

Scrapy downloader middleware that routes every request through ProxyHat residential proxies — rotating IPs, geo-targeting, and sticky sessions.

CI PyPI License: MIT

Why

Scraping at scale from datacenter IPs gets you blocked and rate-limited. This middleware sends your Scrapy requests out through ProxyHat's residential IPs (50M+ across 148+ countries), with a fresh IP per request by default — no boilerplate.

Install

pip install scrapy-proxyhat

Setup

# settings.py
DOWNLOADER_MIDDLEWARES = {
    "scrapy_proxyhat.ProxyHatMiddleware": 610,
}

# Simplest — an API key auto-selects an active residential sub-user:
PROXYHAT_API_KEY = "ph_your_api_key"

# ...or explicit gateway credentials:
# PROXYHAT_USERNAME = "your-proxy-username"
# PROXYHAT_PASSWORD = "your-proxy-password"

# Optional targeting:
PROXYHAT_COUNTRY = "us"          # ISO code or "any" (default)
# PROXYHAT_REGION = "california"
# PROXYHAT_CITY = "new_york"
# PROXYHAT_STICKY = "30m"        # keep one IP; omit for rotating
# PROXYHAT_FILTER = "high"       # AI IP-quality tier
# PROXYHAT_SUBUSER = "<uuid or name>"   # pick a specific sub-user (with API key)

Get an API key at proxyhat.com.

Per-request targeting

Override any setting per request via meta (keys are proxyhat_<setting>):

yield scrapy.Request(
    url,
    meta={"proxyhat_country": "de", "proxyhat_sticky": "30m"},
)

A request that already has meta["proxy"] set is left untouched.

How it works

The middleware builds a ProxyHat gateway connection URL (via the official proxyhat SDK) and sets request.meta["proxy"]. Scrapy's built-in HttpProxyMiddleware (priority 750, runs after this one at 610) moves the credentials into the Proxy-Authorization header. Rotating targeting reuses a stable username so the gateway hands out a fresh residential IP per connection; sticky targeting pins one IP for the session.

License

MIT © ProxyHat

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_proxyhat-0.1.0.tar.gz (84.0 kB view details)

Uploaded Source

Built Distribution

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

scrapy_proxyhat-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file scrapy_proxyhat-0.1.0.tar.gz.

File metadata

  • Download URL: scrapy_proxyhat-0.1.0.tar.gz
  • Upload date:
  • Size: 84.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scrapy_proxyhat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68998b36c7ccbca07f4d45d5f5deddb08f7a881866628824fed583b992e54bea
MD5 b347211ae61d4e55d3dce85e0e1027dd
BLAKE2b-256 aa02fe54cb042423e2e6ae770bef7170443d1a638ed084ba32b42d2e4ad6226f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scrapy_proxyhat-0.1.0.tar.gz:

Publisher: ci.yml on ProxyHatCom/scrapy-proxyhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scrapy_proxyhat-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_proxyhat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfdb17a9bae464367c0134d77e5a4c0a4f66b1407dcf551e9d902db778339501
MD5 30a480664c7d30fc96329f7638d47255
BLAKE2b-256 2f506a3bb45d1436484b000fac23b391f77360220ee50c33c7945420988a9d35

See more details on using hashes here.

Provenance

The following attestation bundles were made for scrapy_proxyhat-0.1.0-py3-none-any.whl:

Publisher: ci.yml on ProxyHatCom/scrapy-proxyhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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