首页 > 解决方案 > Chrome 驱动程序无法与代理一起使用

问题描述

我第一次尝试将 Chrome 驱动程序与代理一起使用,但它似乎不起作用。下面是我的代码:

from selenium import webdriver
    proxy = '1.1.1.1'
    proxy_url = 'https://usr:pwd@' + proxy.strip().rstrip('\n')
    print(proxy_url)
service = webdriver.chrome.service.Service(CHROME_PATH)
service.start()
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--proxy-server=%s' % proxy_url)
options = options.to_capabilities()
driver = webdriver.Remote(service.service_url, options)
driver.set_window_size(1400, 1000)
driver.get("http://google.com")
print(driver.page_source)

无论我使用哪个网站,它都会返回:

<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>

抱歉,我不能分享原始代理,因为它们不属于我。谁能帮我吗?

标签: pythonseleniumselenium-chromedriver

解决方案


推荐阅读