python selenium Chrome Web Driver. How to Proxy IP

2019-09-17 14:02发布

问题:

So i want to make Selenium Project where I need to change my ip to to a specific Cities.For example one in Dallas, One in NewYork, One in Los Angles.

I wanted to know how do I apply a proxy to the chrome web driver using PYTHON. If you guys can show me an example code that would be very helpful. I have seen others with Firefox web driver but not the chrome web Driver.

Also where can i buy a Dedicated IP PROXY for each city. I want to be the only one using that ip Address.

回答1:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=1.2.3.4:8080')
driver = webdriver.Chrome(chrome_options=chrome_options)

driver.get("...")