我在Python中使用chrome和selenium。我有一个在 Chrome 中使用代理的代码,它可以工作,但仅适用于 http 网站(我认为),并且它不会加载 https(ssl)。
我试过这个代码
from selenium import webdriver
http_proxy = "http://118.69.134.2:80"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f'--proxy-server={http_proxy}')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://httpbin.org/ip")
print(driver.find_element(By.TAG_NAME, "body").text)
driver.quit()
失败并显示
ERR_TIMED_OUT
我们可以尝试在webdriver中添加扩展来达到使用代理的目的,前提是你的代理工作正常,请检查:gist