
Hands-on with the Selenium Browser Proxy.
Brothers engaged in automated testing should have encountered the need to switch the proxy scene. Let's not whole false today, directly speak human words to teach you how to Selenium set on the proxy. With our ipipgo proxy service as an example, after all, his family protocol support full live good to make.
from selenium import webdriver
proxy = "123.45.67.89:8888" Replace here with your proxy IP
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f'--proxy-server=http://{proxy}')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://ipinfo.io/") test if the IP works
This code looks simple, right? But there are a fewKey Pit PointsGotta pay attention:
- For http proxy, write http://前缀 and for socks5, write socks5://.
- Don't write the port number wrongly, I've seen people write 8888 as 888!
- The test address do not use Baidu this kind of IP does not show the site, it is recommended to use ipinfo.io this kind of professional testing stations
Configuration differences between browsers
Take Chrome and Firefox, the two major browsers, the proxy settings are really different. Save this comparison table below:
| browser (software) | Configuration | caveat |
|---|---|---|
| Chrome | add_argument | Must be prefixed with protocol |
| Firefox | Profile Settings | The profile object needs to be created |
Firefox's configuration code looks like this:
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "123.45.67.89")
profile.set_preference("network.proxy.http_port", 8888)
driver = webdriver.Firefox(firefox_profile=profile)
How to choose a reliable proxy IP
Here we have to favor our ipipgo service. His family has three main advantages that are particularly suitable for automation scenarios:
- Full coverage of agreements: HTTP/HTTPS/Socks5 random cuts
- Withdrawal is a hassle-free process: API pulls are done in three lines of code
- Client Flexibility: Dedicated client for Windows/Mac
Take a real scenario: do cross-border e-commerce brothers need to open 10 browser windows at the same time, each window with a different country IP. ipipgo API batch get IP, with multi-threaded direct takeoff.
Frequently Asked Questions QA
Q: What should I do if the proxy setting is successful but the IP is not changed?
A: First check if the IP format is right, then try manual curl test. If it does not work, the IP may be blocked, it is recommended to change ipipgo's exclusive static IP.
Q: Browser startup suddenly slows down?
A: 80% is the proxy server response delay, change to ipipgo's TK line can be a lot faster.
Q: What if I need a long term stable IP?
A: directly on the ipipgo static residential package, 35 dollars a month fixed IP, do crawl brother said incense.
Lastly, I'd like to give you a piece of advice: don't be cheap and use a free proxy, you'll be blocked in minutes, not to mention the IP, data security is not guaranteed. ipipgo's dynamic residential packages are as low as 7 more than 1G traffic, cheaper than drinking milk tea, and you can't afford to spend the money you have.

