1
我想在C#中使用fiddlercore捕获请求头。这是我的代码。我使用硒来到我想要获取请求标题/网络表单的网页。我能够访问网页,但无法使用fiddlercore捕获任何内容。我知道我必须使用委托和BeginInvoke方法,但应该怎么做还不清楚。 我正在使用AfterSessionComplete事件来捕获请求正文。然而它是空的。我错过了什么?有人可以帮我解决这个问题吗?谢谢。这是我的代码。如何在C#中使用Fiddlercore捕获http请求?
public void requestURL()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com");
IWebElement query = driver.FindElement(By.Name("q"));
// search Cheese
query.SendKeys("Cheese");
//// submit query
query.Submit();
// Wait for the page to load, timeout after 10 seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.StartsWith("Cheese"); });
// Should see: "Cheese - Google Search"
Console.WriteLine("Page title is: " + driver.Title);
Console.WriteLine("URL for page is: " + driver.Url);
}
static void Main(string[] args)
{
FiddlerApplication.Startup(8877, FiddlerCoreStartupFlags.DecryptSSL);
HttpActions h = new HttpActions();
h.requestURL();
FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
FiddlerApplication.Shutdown();
}
static void FiddlerApplication_AfterSessionComplete(Session oSession)
{
var s = oSession.GetRequestBodyAsString();
}
吉姆·埃文斯,涉及与硒的开发者之一,广泛覆盖在这里它:http://jimevansmusic.blogspot.co.uk/ – Arran 2014-08-28 10:06:40