因此,以下是我试用浏览器代理的基本代码,并生成了输出。
问题出在输出上,它看起来(1)数量不完整,(2)不够详细,不如我在开发工具(Firefox或Chrome)中手动检查网络统计信息那样。

HAR文件中可能有更详细的信息吗?我想知道,例如,是否已加载特定的Javascript(或对此有更好的解决方案?)。

        // Supply the path to the Browsermob Proxy batch file
        Server server = new Server(@"C:\Users\Frederik\Desktop\SeleniumTestje\browsermob-proxy-2.1.0-beta-6\bin\browsermob-proxy.bat");
        server.Start();

        Client client = server.CreateProxy();
        client.NewHar("google");

        var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
        var profile = new FirefoxProfile();

        profile.SetProxyPreferences(seleniumProxy);
        // Navigate to the page to retrieve performance stats for
        IWebDriver driver = new FirefoxDriver(profile);
        driver.Navigate().GoToUrl("http://www.google.co.uk");

        // Get the performance stats
        HarResult harData = client.GetHar();
        foreach(Entry e in harData.Log.Entries)
        {
            Console.WriteLine(e.Request.Url, e.Request.Headers);
        }


在控制台中输出:

http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://www.google.co.uk/
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp

最佳答案

我在Fiddlercore中遇到了同样的问题,但是我找到了解决方案:
Fiddlercore - Requested resource URL's are generic (OSCP-related) instead of actual resource

关于c# - Browsermob Proxy-HAR文件不如手动HAR完整吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36848563/

10-10 21:43