简体   繁体   English

有没有办法让 browsermob-proxy 服务于 HTTPS 请求?

[英]Is there are any way to make browsermob-proxy serve HTTPS request?

I use Selenium's ChromeDriver in order to test loading time with certain js file.我使用 Selenium 的 ChromeDriver 来测试某些 js 文件的加载时间。 And for that I used browsermob-proxy python server.为此,我使用了browsermob-proxy python 服务器。 Approach is方法是

  1. Start proxy server启动代理服务器
  2. Block certain website via blacklist function.通过blacklist功能阻止某些网站。
  3. Open Chrome driver with an argument proxy-server使用参数proxy-server打开 Chrome 驱动程序

    chrome_options = webdriver.ChromeOptions()
    proxy_url = urlparse(Crawler.proxy.proxy).path
    chrome_options.add_argument('--proxy-server=%s' % proxy_url)
    Crawler.proxy.blacklist(".*my-js-lays-here.*", 200)
    Crawler.driver = webdriver.Chrome(path, chrome_options=chrome_options)

Problem is that my proxy can't handle HTTPS requests and this results in forever loading website.问题是我的代理无法处理 HTTPS 请求,这导致网站永远加载。 I searched all the way throught browsermob-proxy documentation, but didn't find any code example on how to handle https requests.我一直搜索browsermob-proxy文档,但没有找到任何关于如何处理 https 请求的代码示例。

Try to accept the certs and if it still doesn't work change your proxy server settings尝试接受证书,如果它仍然不起作用,请更改您的代理服务器设置

from selenium.webdriver import DesiredCapabilities

...

capabilities = DesiredCapabilities.CHROME.copy()
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True

driver = webdriver.Chrome(options=chrome_options,
    desired_capabilities=capabilities,
    executable_path=config.CHROME_PATH)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到 Browsermob-proxy ProxyServerError - Can't connect to Browsermob-proxy ProxyServerError python selenium browsermob-proxy和拦截器 - python selenium browsermob-proxy and interceptor Browsermob-Proxy 服务器进程启动失败 - The Browsermob-Proxy server process failed to start 如何修复 Mac 上的“无法连接到 Browsermob-Proxy”? - How to fix “Can't connect to Browsermob-Proxy” on a mac? 错误:10061,“无法建立连接” Browsermob-proxy - Error:10061, 'No connection could be made' Browsermob-proxy 作为pypi包安装时browsermob-proxy的路径应该是什么 - What should be the path of browsermob-proxy when installed as pypi package 如何从 Browsermob-proxy 获取标头? - How do i get headers from Browsermob-proxy? 带有 Pyhton 的 BrowserMob 代理 - BrowserMob 代理服务器进程无法启动 - 看到 server.log 中不允许操作 - BrowserMob Proxy with Pyhton - The Browsermob-Proxy server process failed to start - Seeing Operation not permitted in server.log 即使安装了所需的代理,也会出现错误“在提供的路径中找不到 Browserrmob-Proxy 二进制文件” - Getting error 'Browsermob-Proxy binary couldn't be found in path provided' even after installing required proxy 无法使用带有 BrowserMob-Proxy 的 Python Selenium 脚本捕获 HAR - Can't capture HAR using Python Selenium Script with BrowserMob-Proxy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM