Python 硒蟒蛇罐头';无法使用代理连接到网站
我正在尝试将Selenium与chrome驱动程序一起使用,并使用代理连接到网站,但由于一些奇怪的原因,chrome返回了一个错误,即连接被重置或连接超时,或者无法访问此网站等等。。使用了许多代理,因此我怀疑代理服务器是否有故障 这是我的密码:Python 硒蟒蛇罐头';无法使用代理连接到网站,python,selenium,proxy,selenium-chromedriver,Python,Selenium,Proxy,Selenium Chromedriver,我正在尝试将Selenium与chrome驱动程序一起使用,并使用代理连接到网站,但由于一些奇怪的原因,chrome返回了一个错误,即连接被重置或连接超时,或者无法访问此网站等等。。使用了许多代理,因此我怀疑代理服务器是否有故障 这是我的密码: from selenium import webdriver chromedriver = r'C:/Users\seife\Documents\chromedriver\chromedriver.exe' PROXY = "177.202.59.58
from selenium import webdriver
chromedriver = 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")
以下是页面的外观:
我做了更改,使用了许多代理,包括您的代理,但仍然无法连接;/,你的chrome版本是什么??,无论如何谢谢你的帮助,我很感激!。从这里尝试使用不同的代理。我的chrome版本是83。您是否尝试过更改标题?也可以尝试更改用户代理。您可以从user-agents.net获得免费的用户代理,也可以使用fake_headers模块。“chrome_options.add_参数(f'user-agent={user-agent}')”类似这样的东西我有v.81 chromedriver,也许我是过时的idk。它工作得很好,但速度非常慢,可能是因为有免费代理。是的,免费代理通常速度很慢,你也可以使用VPN
#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