【问题标题】:BrowserMob proxy doesn't blacklist https resourcesBrowserMob 代理不会将 https 资源列入黑名单
【发布时间】:2016-07-07 17:54:07
【问题描述】:

我正在使用代理排除第三方资源。但是我对所有以 https 开头的资源都有疑问。你能建议任何解决方案吗? 例如,我试图从 http://linkedin.com 中排除 static.licdn.com 。它改变状态但下载资源。

   public void setUp()    
    throws Exception
{
    setName("test");
    try
    {
        FirefoxBinary firefoxbinary = new FirefoxBinary(new File("firefoxpath"));
        File file = new File("profilePath");
        FirefoxProfile firefoxprofile = new FirefoxProfile(file);
        firefoxprofile.setPreference("browser.startup.homepage", "http://www.google.com");
        BrowserMobProxyServer server = new BrowserMobProxyServer();
        server.start();
        ArrayList arraylist = new ArrayList();
        arraylist.add(new BlacklistEntry(".*static\\.licdn\\.com.*", 204));
        server.setBlacklist(arraylist);
        org.openqa.selenium.Proxy proxy = ClientUtil.createSeleniumProxy(server);
        proxy.setSslProxy("localhost:" + server.getPort());
        DesiredCapabilities desiredcapabilities = new DesiredCapabilities();
        desiredcapabilities.setCapability("proxy", proxy);
        desiredcapabilities.setCapability("acceptSslCerts", true);
        driver = new FirefoxDriver(firefoxbinary, firefoxprofile, desiredcapabilities);
    }
    catch(Throwable throwable)
    {
        LOG.error("Problem in setup: ", throwable);
    }
}
  • 浏览器版本:2.1.1
  • 硒版本:2.53
  • FF 版本:46

【问题讨论】:

  • 您遇到了什么问题?你说你看到了状态码,但是代理仍然获取资源,但是如果一个条目被列入黑名单,BMP 就不可能这样做。另外:Firefox 实例在哪里运行?如果您使用 .createSeleniumProxy(),通常不需要显式调用 .setSslProxy(),但您将其显式设置为“localhost”,这意味着 Firefox 必须与 BMP 在同一台机器上运行。
  • 问题与https资源有关。如果 recourse 是 https 则不排除
  • 我用不同的主机重现了这个问题,但借用你的来提交错误报告:github.com/lightbody/browsermob-proxy/issues/509

标签: java selenium-webdriver proxy browsermob browsermob-proxy


【解决方案1】:

解决方案 - 我们只是编写自定义插件来排除第三方库。不幸的是,由于项目政策,我无法分享我的代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-15
    • 2022-08-11
    • 2012-10-06
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 2017-09-01
    相关资源
    最近更新 更多