ProxyHat residential proxies for Selenium — authenticated Chrome via an auto-generated auth extension, sticky sessions, geo-targeting, rotation.
Project description
selenium-proxyhat
Route Selenium Chrome through ProxyHat residential proxies — authenticated gateway proxies that just work in vanilla Selenium, plus a sticky residential IP pinned for the whole session, geo-targeting, and rotation.
Why
Chrome's --proxy-server flag can't carry a username and password, so pointing Selenium at a credentialed residential gateway normally means an ugly page.authenticate / CDP dance or an extra proxy dependency. And running a real browser from a datacenter IP gets flagged, CAPTCHA-walled, and blocked anyway.
selenium-proxyhat fixes both. It plugs ProxyHat's residential IPs (50M+ across 148+ countries) into Selenium and handles gateway auth by auto-generating a tiny in-memory Chrome extension that answers the proxy's auth challenge — works with vanilla Selenium, no selenium-wire required. One pinned residential IP per session by default, so cookies and fingerprint stay consistent while your script works.
Install
pip install selenium-proxyhat
selenium>=4.10 and proxyhat come with it. Bring your own Chrome + chromedriver (Selenium Manager resolves the driver for you).
Quick start
from selenium_proxyhat import proxyhat_driver
# An API key (PROXYHAT_API_KEY) auto-selects an active residential sub-user:
driver = proxyhat_driver(country="us") # sticky US IP for the whole session
driver.get("https://httpbin.org/ip")
print(driver.find_element("tag name", "body").text)
driver.quit()
Get an API key at proxyhat.com.
Prefer to build the driver yourself? Get configured ChromeOptions (proxy flag + auth extension already applied) and launch Chrome your way:
from selenium import webdriver
from selenium_proxyhat import proxyhat_chrome_options
options = proxyhat_chrome_options(country="de", sticky="1h")
options.add_argument("--headless=new") # add whatever else you need
driver = webdriver.Chrome(options=options)
Credentials
Pass them explicitly or via environment variables — options win over env:
| Option | Env var | Notes |
|---|---|---|
api_key |
PROXYHAT_API_KEY |
Auto-selects an active sub-user with remaining traffic |
sub_user |
PROXYHAT_SUBUSER |
Pick a specific sub-user by uuid or name (with an API key) |
username |
PROXYHAT_USERNAME |
Explicit gateway proxy_username (skips the API) |
password |
PROXYHAT_PASSWORD |
Explicit gateway proxy_password |
Targeting
proxyhat_chrome_options(
country="us", # ISO code or "any" (default)
region="california",
city="new_york",
filter="high", # AI IP-quality tier
sticky="30m", # session lifetime (default); sticky=False rotates every request
)
Same keyword arguments work on proxyhat_driver(...) and proxyhat_seleniumwire_options(...).
Sticky IP per session (default)
A browser session takes many steps against the same site — logging in, clicking, scrolling. If the exit IP changed mid-session the site would see a user teleporting between cities and block it. So this package is sticky by default: one residential IP is pinned for the whole session (sticky="30m", renewed as you work), keeping cookies and fingerprint coherent.
Want a fresh IP on every request instead (e.g. many independent one-shot fetches)? Turn stickiness off:
proxyhat_chrome_options(country="us", sticky=False) # rotating residential IP per connection
Set a custom lifetime with sticky="2h".
How authentication works
Chrome takes the proxy host/port from --proxy-server=gate.proxyhat.com:8080, but a residential gateway needs a username (the ProxyHat targeting string) and password. Since the flag can't carry them, proxyhat_chrome_options generates a minimal Manifest V3 extension in memory whose background service worker answers chrome.webRequest.onAuthRequired with your credentials, and adds it via ChromeOptions.add_extension. The MV3 blocking auth listener is enabled by the webRequestAuthProvider permission. Nothing is written to your project — the packed extension lives in a temp file that Chrome reads at launch.
The targeting username (e.g. <user>-country-us-sid-<id>-ttl-30m) is built by the official proxyhat SDK, so a sticky session mints a single session id shared across the run.
selenium-wire alternative (optional)
Already using selenium-wire? Skip the extension and let selenium-wire carry credentials in the upstream-proxy URL:
from seleniumwire import webdriver # pip install selenium-proxyhat[seleniumwire]
from selenium_proxyhat import proxyhat_seleniumwire_options
driver = webdriver.Chrome(
seleniumwire_options=proxyhat_seleniumwire_options(country="us"),
)
# -> {"proxy": {"http": "http://<user>:<pass>@gate.proxyhat.com:8080", "https": ..., "no_proxy": ...}}
selenium-wire is an optional extra; proxyhat_seleniumwire_options() only builds the dict and never imports it. It also supports protocol="socks5" for an authenticated SOCKS5 upstream (which the extension path does not).
License
MIT © ProxyHat
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file selenium_proxyhat-0.1.0.tar.gz.
File metadata
- Download URL: selenium_proxyhat-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ef1d2345ebc73effe9424c5b1885cd76920065c4cce51a442ad3997c201b7b
|
|
| MD5 |
39c352623825ecdf8a52c02073c75285
|
|
| BLAKE2b-256 |
7ca5ef0e412c8f1fad5ad85f43400ec99ba077008e225ae251182c14045841d0
|
Provenance
The following attestation bundles were made for selenium_proxyhat-0.1.0.tar.gz:
Publisher:
ci.yml on ProxyHatCom/selenium-proxyhat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selenium_proxyhat-0.1.0.tar.gz -
Subject digest:
d2ef1d2345ebc73effe9424c5b1885cd76920065c4cce51a442ad3997c201b7b - Sigstore transparency entry: 2164579022
- Sigstore integration time:
-
Permalink:
ProxyHatCom/selenium-proxyhat@8786b555c0aa25aa1679de5f25688f6f9446066a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ProxyHatCom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@8786b555c0aa25aa1679de5f25688f6f9446066a -
Trigger Event:
push
-
Statement type:
File details
Details for the file selenium_proxyhat-0.1.0-py3-none-any.whl.
File metadata
- Download URL: selenium_proxyhat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
742a3715785bf4f9091c44e26518779d169a8e6f3562c581141a65412a36b405
|
|
| MD5 |
d282f984233c2a3b2196f4103107a964
|
|
| BLAKE2b-256 |
40eb53f5972518f79fb427892851fa96c9ac2d68c2a7391d871a433c0ac0f836
|
Provenance
The following attestation bundles were made for selenium_proxyhat-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on ProxyHatCom/selenium-proxyhat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selenium_proxyhat-0.1.0-py3-none-any.whl -
Subject digest:
742a3715785bf4f9091c44e26518779d169a8e6f3562c581141a65412a36b405 - Sigstore transparency entry: 2164579040
- Sigstore integration time:
-
Permalink:
ProxyHatCom/selenium-proxyhat@8786b555c0aa25aa1679de5f25688f6f9446066a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ProxyHatCom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@8786b555c0aa25aa1679de5f25688f6f9446066a -
Trigger Event:
push
-
Statement type: