Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Chrome驱动程序不与代理一起工作_Python_Selenium_Selenium Chromedriver - Fatal编程技术网

Python Chrome驱动程序不与代理一起工作

Python Chrome驱动程序不与代理一起工作,python,selenium,selenium-chromedriver,Python,Selenium,Selenium Chromedriver,我第一次尝试将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

我第一次尝试将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>


很抱歉,我不能共享原始代理,因为它们不属于我。有人能帮我吗?

您是否在chrome中手动设置此代理?@Sraw。。不但代理正在发挥作用。你还想说什么?