Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Playwright Proxy Example — Per-Context Geo-Targeting (Python)

Playwright supports proxies natively, including credentials in the launch options (no authenticate() dance like Puppeteer) and — the killer feature — a different proxy per browser context. One Chromium process, N countries.

Basic: proxy for the whole browser

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={
        "server": "http://residentialboson.quantumproxies.io:10000",
        "username": "YOUR_USERNAME-country-us-session-pw1-lifetime-30",
        "password": "YOUR_PASSWORD",
    })
    page = browser.new_page()
    page.goto("https://ipinfo.io/json")
    print(page.inner_text("body"))

Per-context: one browser, many countries

browser = p.chromium.launch(proxy={"server": "per-context"})

us = browser.new_context(proxy={
    "server": "http://residentialboson.quantumproxies.io:10000",
    "username": "YOUR_USERNAME-country-us-session-us1-lifetime-30",
    "password": "YOUR_PASSWORD",
})
jp = browser.new_context(proxy={
    "server": "http://residentialboson.quantumproxies.io:10000",
    "username": "YOUR_USERNAME-country-jp-session-jp1-lifetime-30",
    "password": "YOUR_PASSWORD",
})

This is the cheapest way to check localized pricing, ad delivery, or search results side-by-side — each context is an isolated cookie jar exiting from its own country, but you pay the launch cost of a single browser.

Run the demo (prints your exit IP from 3 countries):

pip install playwright && playwright install chromium
QP_USER=... QP_PASS=... python example.py

Notes

  • Use the sticky port 10000 with a -session- flag: a browser context firing 50 sub-requests from 50 different IPs is an instant block.
  • Mobile pages? Swap in 4G/5G mobile proxies — carrier-grade IPs that mobile-first sites treat as real phones.

Credentials come from QuantumProxies — residential and mobile pools, 195+ countries, per-GB billing. Register at app.quantumproxies.io.

About

Playwright per-context proxies in Python: one browser, many countries — geo-testing localized pages.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages