python - 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>
抱歉,我不能分享原始代理,因为它们不属于我。谁能帮我吗?
解决方案
推荐阅读
- r - RDCOMClient 日志文件
- javascript - RangError:为函数调用提供的参数过多
- android-studio - 在generatedJava下添加文件夹
- php - 如何使用php显示word文件和excel文件
- paraview - Paraview 没有将控制权释放回壳牌
- c# - 在c#中增加属性的setter方法中的计数
- node.js - 在没有 Firefox 跟踪器阻止的情况下嵌入 Facebook 帖子
- protractor - 我们可以在量角器中的测试运行之间更改多重功能吗
- git - 创建一个分支并使用不同的存储库分支对其进行跟踪
- php - 使用基本授权作为中间件 PSR-7 PSR-15