使用Selenium Python用白名单IP设置代理

时间:2019-09-12 16:11:39

标签: python python-3.x selenium selenium-chromedriver

我完全理解下面的代码,只有一行。 我订阅了代理提供程序(Proxymesh),并从那里将我的IP列入白名单。

我的问题似乎很简单,但我不知道该如何解决:我如何才能将可用的ip用作PROXY变量(此处为23.23 ...作为示例)?我不断收到空白的Chrome窗口,出现代理错误...

非常感谢

from selenium import webdriver

PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(options=chrome_options)
chrome.get("http://whatismyipaddress.com")

0 个答案:

没有答案