Install
The Python package, then the browser it drives. The Node.js API takes the same proxy object.
pip install playwright && playwright install chromiumRotating residential
Credentials go in their own fields, and server holds only the scheme, host and port. Launch-level proxy settings apply to every page the browser opens.
from playwright.sync_api import sync_playwright
PROXY = {
"server": "http://resi.proxymonkey.io:8000",
"username": "USER",
"password": "PASS",
}
with sync_playwright() as p:
browser = p.chromium.launch(proxy=PROXY)
page = browser.new_page()
page.goto("https://httpbin.org/ip")
print(page.inner_text("body"))
browser.close()A static datacenter or ISP IP
Give each context its own proxy. Here one context runs on the static datacenter IP; a second could use an ISP order with the host and port from your dashboard. Contexts do not share cookies or storage, so they look like separate visitors.
from playwright.sync_api import sync_playwright
DATACENTER = {
"server": "http://IP:PORT",
"username": "USER",
"password": "PASS",
}
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context(proxy=DATACENTER)
page = context.new_page()
page.goto("https://httpbin.org/ip")
print(page.inner_text("body"))
context.close()
browser.close()Keeping one identity
One page load is dozens of requests: HTML, scripts, fonts, API calls. On the rotating gateway those can leave from different addresses, and some sites notice a visitor whose IP changes between the page and its scripts. For browser work that logs in or clicks through several pages, use a static datacenter or ISP IP per context, or a residential sticky session; the session setting for your account is in the dashboard.