A considerable portion of the current web pages are used
Ajax Technically, neither WebClient nor httprequest in C # can get the correct results, because these scripts are executed after the server sends them!
However, it is normal when we use IE to browse the page, so only one solution is to useWebbrowserWidget
HoweverWebbrowserYou will find that in the downloadcomplete event, you cannot know when the page is actually loaded!
Of course, a webpage with a frame may trigger complete multiple times, even if you use the counter method, that is, in the navigated event ++, but in downloadcomplete --, still cannot get the result after JS execution is complete, and I also felt very strange at first, until ggAjaxOfArticle, Understand the original committee.
The final solution is to useWebbrowser+ Timer to solve the page grabbing Problem
The key is still the page status. We can use webbrowser1.statustext. If "finished" is returned, the page is loaded!
ExampleCodeAs follows:
Private Void Timereffectick ( Object Sender, eventargs E)
{
Textbox1.text + = Webbrowser1.statustext;
If (Webbrowser1.statustext = " Complete " )
{
Timer1.enabled = False ;
// Page loading is complete. Do some other things
Textbox1.text + = Webbrowser1.document. Body. outerhtml;
// Do not use webbrowser1.documenttext. This is the same as viewing source files.
}
}
Private Void Form1_load ( Object Sender, eventargs E)
{
String URL = " Http://cd.mei8.cn/face/work/windex.aspx? BTN = 6 " ;
Webbrowser1.navigate (URL );
}
Put three controls,Webbrowser, Timer, textbox
Set timer to available