Prompt
How do I use proxies with Selenium?
Latest observation
You can use proxies with Selenium by configuring the browser instance to route traffic through the proxy server. The exact setup depends on the browser and whether the proxy needs authentication.
1) Basic proxy setup
Python + Chrome
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
proxy = "http://proxy-host:proxy-port"
options = Options()
options.add_argument(f'--proxy-server={proxy}')
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
Python + Firefox
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.proxy import Proxy, ProxyType
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = "proxy-host:proxy-port"
proxy.ssl_proxy = "proxy-host:proxy-port"
capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()
proxy.add_to_capabilities(capabilities)
driver = webdriver.Firefox(desired_capabilities=capabilities)
driver.get("https://example.com")
2) Proxy with authentication
Chrome
Chrome does not handle proxy username/password well via simple command-line args. Common approaches:
- Use a Chrome extension to supply credentials
- Use a local proxy tool that injects credentials
- Use Selenium Wire or another library that supports authenticated proxies more easily
Example with selenium-wire:
from seleniumwire import webdriver
options = {
'proxy': {
'http': 'http://username:password@proxy-host:proxy-port',
'https': 'https://username:password@proxy-host:proxy-port',
'no_proxy': 'localhost,127.0.0.1'
}
}
driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://example.com")
Install:
pip install selenium-wire
3) SOCKS proxy
Chrome
options.add_argument('--proxy-server=socks5://proxy-host:proxy-port')
Firefox
proxy.socks_proxy = "proxy-host:proxy-port"
proxy.socks_version = 5
4) Check that the proxy is working
Use a site that shows your IP:
driver.get("https://api.ipify.org?format=json")
print(driver.page_source)
5) Notes / common issues
- If the site uses HTTPS, make sure your proxy supports HTTPS tunneling.
- If pages fail to load, test the proxy outside Selenium first.
- Some proxies require additional cert handling for HTTPS interception.
- Rotating proxies often need per-session configuration.
If you want, I can give you a ready-to-run example for Chrome, Firefox, or authenticated proxies in your preferred language.
Observation history
Unlock observation history
Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.
How did Obsurfable measure this prompt?
Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.
Which AI systems does Obsurfable collect answers from?
OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.