BrowserMob请求内容为空? C#

时间:2019-11-27 16:54:51

标签: c# selenium selenium-webdriver browsermob

我正在尝试使用BrowserMob和Selenium获取此页面的内容,当我编写har文件时,我没有得到响应的内容。有人知道如何获取内容吗?

                Server server = new Server("browsermob-proxy.bat");
                server.Start();
                Client client = server.CreateProxy();
                client.NewHar("ip-api");
                var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
                var profile = new FirefoxProfile();
                profile.SetProxyPreferences(seleniumProxy);
                IWebDriver driver = new FirefoxDriver(profile);
                driver.Navigate().GoToUrl("https://ip-api.com");
                HarResult harData = client.GetHar();
                var json = new JavaScriptSerializer().Serialize(harData);
                Log log = harData.Log;
                Entry[] entries = log.Entries;

                var file = new StreamWriter(@"file.har");
                file.WriteLine(json);

                foreach (var e in entries)
                {
                    Request request = e.Request;
                    Response response = e.Response;
                    MessageBox.Show(response.Content.Text);
                }

0 个答案:

没有答案