亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Selenium Python 無法使用代理連接到網站

Selenium Python 無法使用代理連接到網站

泛舟湖上清波郎朗 2022-12-27 15:33:30
我正在嘗試將 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


查看完整回答
反對 回復 2022-12-27
  • 1 回答
  • 0 關注
  • 332 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號