Skip to main content

Authenticated proxies for Selenium + Chrome without selenium-wire. Generates a proxy-auth extension on the fly.

Project description

selenium-proxy-auth

PyPI version Python versions License: MIT

Use an authenticated (user:pass) proxy with Selenium + Chrome — without selenium-wire. It generates a tiny proxy-auth extension on the fly and loads it, so Chrome never shows the native auth popup that Selenium can't click.

pip install selenium-proxy-auth

The problem

Chrome's --proxy-server flag has nowhere to put a username and password. So with an authenticated proxy, Chrome throws a native auth dialog — which Selenium can't interact with — and every request hangs or 407s:

# ❌ no place for credentials; Chrome shows a popup Selenium can't dismiss
opts.add_argument("--proxy-server=http://user:pass@gw.example.com:913")

The reliable fix is a small extension that sets chrome.proxy and answers onAuthRequired with your credentials. This package builds and loads it for you.

Usage

import shutil
from selenium import webdriver
from selenium_proxy_auth import add_proxy

opts = webdriver.ChromeOptions()
opts.add_argument("--headless=new")

ext = add_proxy(opts, "http://USERNAME:PASSWORD@us.jibaoproxy.com:913")

driver = webdriver.Chrome(options=opts)
try:
    driver.get("https://httpbin.org/ip")
    print(driver.find_element("tag name", "body").text)
finally:
    driver.quit()
    shutil.rmtree(ext, ignore_errors=True)   # clean up the generated extension

add_proxy returns the path to the generated extension directory so you can delete it afterwards. The extension contains your credentials in plaintext — it's written to a temp dir; don't commit it.

How it works

  • Manifest V3 extension with the proxy, webRequest, and webRequestAuthProvider permissions.
  • A background service worker sets chrome.proxy.settings to your host:port and returns authCredentials from onAuthRequired.
  • Loaded via --load-extension, so it works in headless --headless=new. (Old --headless does not load extensions; use --headless=new.)

Need just the files (e.g. for undetected-chromedriver)? Use make_proxy_extension(url) to get the directory and load it yourself.

Rotating IPs

A rotating residential gateway hands out a new exit IP per connection from one URL — point add_proxy at the gateway and each fresh webdriver.Chrome gets a different IP. If you're still getting blocked after authenticating, the exit IP is the issue: datacenter ranges get scored as bots by ASN and TLS fingerprint before the page loads. We build JiBao Proxy for clean residential exits — 72M+ IPs, 200+ countries, sticky sessions. Works with any provider, though.

Related

License

MIT

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

selenium_proxy_auth-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

selenium_proxy_auth-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: selenium_proxy_auth-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for selenium_proxy_auth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 784a61a3e21867e2ab8ab4bcfa317462689bb841c3620441d0c4de745ff49a08
MD5 f71a73ef600ccd61fa8bb949729e3174
BLAKE2b-256 b424568ec6192d929e3a2fa7de2c7e51377ad36170835bc34405c6c8f44a4c74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for selenium_proxy_auth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7b5b72ca8f7f7909b65066a9a0b3e0a7670c2d1cff7c5d84f24ec674994315f
MD5 27293941df309885bb2e9a69ec535380
BLAKE2b-256 5fb2061a94677a03e899cd023dc40712d700680b10384959a8c982cbdf0b7bee

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