01Why the usual flag is not enough
--proxy-server=http://user:pass@host:port looks right but does not work: Chrome drops the login part and then shows a sign-in prompt that WebDriver cannot fill. Every proxy login needs some way to answer that prompt.
SeleniumBase is a Selenium wrapper that answers it for you. You keep writing Selenium code; the driver it returns is a normal WebDriver.
02Selenium with SeleniumBase
pip install seleniumbase, then pass the proxy as login:password@host:port:
from seleniumbase import Driver
driver = Driver(browser="chrome", headless=True,
proxy="USERNAME-country-us:PASSWORD@gw.fullstackproxy.com:47631")
try:
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
finally:
driver.quit()As in any browser, one page opens many connections. Add a session so the whole visit shares one IP: USERNAME-country-us-session-s1-lifetime-30.
03With an ISP proxy
An ISP proxy works the same way, with the host, port, login and password that came with that address. Because the IP never changes, the browser profile and the address stay together from one run to the next.
driver = Driver(browser="chrome", proxy="LOGIN:PASSWORD@203.0.113.42:PORT")