问题
So there is a button call next (page). Its href link is site/blah/#. So i know its really running javascript code. After i finish parsing the first page i would like to parse the next page. How do i simulate a mouse click there so i can continue loading and parsing pages?
i am using C# .NET
回答1:
childElement.RaiseEvent("OnClick");
回答2:
If you know the id of the tag you can use below given code
WebBrowser1.Document.GetElementById("submit").InvokeMember("click")
if you dont know the id you can follow this code
foreach (System.Windows.Forms.HtmlElement html in WebBrowser1.Document.GetElementsByTagName("a")) {
if (html.InnerText == "YOUR TEXT") {
html.InvokeMember("click");
}
}
Contact if you have any doubt
来源:https://stackoverflow.com/questions/1161207/how-do-i-simulate-a-click-event-in-a-webbrowser-control-net