Python Chrome驱动程序不与代理一起工作
我第一次尝试将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
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。。不但代理正在发挥作用。你还想说什么?