我正在嘗試將 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
提交
取消