我正在尝试将 Selenium 与 chrome 驱动程序一起使用并使用代理连接到网站,但由于某些奇怪的原因,chrome 返回错误,连接已重置或连接超时或无法访问该站点等等。使用了很多代理,所以我怀疑代理服务器有问题。这是我的代码:from selenium import webdriverchromedriver = r'C:/Users\seife\Documents\chromedriver\chromedriver.exe'PROXY = "177.202.59.58:8080"chrome_options = webdriver.ChromeOptions()chrome_options.add_argument('--proxy-server=%s' % PROXY)chrome = webdriver.Chrome(chromedriver, options=chrome_options)chrome.get("http://whatismyipaddress.com")该页面的外观如下:
1 回答
喵喔喔
TA贡献1735条经验 获得超5个赞
#you need to import Options
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
chromedriver = r'C:/Users\seife\Documents\chromedriver\chromedriver.exe'
PROXY = "177.202.59.58:8080" #free proxies sometimes don't work, I tried with netherland's proxy, and it worked
chrome_options = Options() #here is the change
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(chromedriver, options=chrome_options)
chrome.get("https://whatismyipaddress.com") #and here is the change, just https
添加回答
举报
0/150
提交
取消