Authenticated and rotating proxies for Playwright — turn user:pass proxy URLs into Playwright's proxy dict and rotate per context.
Project description
playwright-proxy-authentication
Use authenticated and rotating proxies with Playwright without fighting its proxy API. Turn an ordinary scheme://user:pass@host:port URL into the dict Playwright expects, and hand out a fresh exit IP per browser context.
pip install playwright-proxy-authentication
The problem
Unlike requests or Scrapy, Playwright ignores credentials in a proxy URL. This silently fails to authenticate:
# ❌ username/password are dropped — you get 407 Proxy Authentication Required
browser.new_context(proxy={"server": "http://user:pass@gw.example.com:913"})
Playwright wants the parts split out:
# ✅ correct
browser.new_context(proxy={
"server": "http://gw.example.com:913",
"username": "user",
"password": "pass",
})
This package does that conversion for you, and adds per-context rotation.
Usage
from playwright.sync_api import sync_playwright
from playwright_proxy_auth import ProxyPool
# A rotating residential gateway gives a new exit IP on every connection.
pool = ProxyPool(gateway="http://USERNAME:PASSWORD@us.jibaoproxy.com:913")
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
for _ in range(3):
context = browser.new_context(proxy=pool.get()) # fresh IP per context
page = context.new_page()
page.goto("https://httpbin.org/ip")
print(page.inner_text("body"))
context.close()
browser.close()
Static list instead of a gateway:
pool = ProxyPool(proxies=[
"http://USERNAME:PASSWORD@proxy-a.example.com:8000",
"http://USERNAME:PASSWORD@proxy-b.example.com:8000",
])
One-off conversion without the pool:
from playwright_proxy_auth import to_playwright_proxy
proxy = to_playwright_proxy("http://user:pass@gw.example.com:913")
browser.new_context(proxy=proxy)
See examples/ for the async version.
Gotchas this saves you from
- Credentials in the URL are ignored — they must be a separate
username/password. (Main reason for it.) - Authenticated SOCKS5 is not supported by Playwright. A
socks5://user:pass@…URL raises a clear error instead of failing silently — use an HTTP/HTTPS gateway for authenticated rotation. - Proxy is per context, not per page. Rotate by creating a new
browser.new_context(proxy=...); pages inside a context share its exit IP.
A note on getting blocked anyway
A correctly authenticated proxy still gets blocked if the exit IP is a datacenter range — anti-bot systems score the ASN and TLS/JA3 fingerprint before your page loads. Residential exits with clean ASN reputation are what pass. We build JiBao Proxy for this: 72M+ residential IPs across 200+ countries with sticky sessions. This package works with any HTTP proxy provider, though.
Related
- Selenium & Playwright proxy authentication, explained
- Why your JA3/TLS fingerprint gets you blocked
- browser-use & AI agent proxies
License
MIT
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 playwright_proxy_authentication-0.1.0.tar.gz.
File metadata
- Download URL: playwright_proxy_authentication-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
641e7a7f7c82c1096b7ce7da17c48ca240636546ceee57339c7e5c2bd22a2fb9
|
|
| MD5 |
fe47fc698604449ed2dc18f61782038d
|
|
| BLAKE2b-256 |
adbad6d6d3d16e0ae6e95201db9e55e2bc08e5e4b1ccf97b5f869727a7d539c0
|
File details
Details for the file playwright_proxy_authentication-0.1.0-py3-none-any.whl.
File metadata
- Download URL: playwright_proxy_authentication-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
056c0ee108c867db7aa18b2c7791f0ea0944affff32cfb14f645acd9b2525893
|
|
| MD5 |
725142de3c288870a390e336fa08a298
|
|
| BLAKE2b-256 |
74973d44200ea99a191e0671f1828c4f2836adb6b699d69411c8e76193b15ecc
|