I am trying to get data (which is generated by scripts) and I am using webbrowser control applied the introduction from: C# webbrowser Ajax call
My 1st main code is:
webBrowser1.Navigate("https://mobile.bet365.com/#type=Coupon;key=1-1-13-33977144-2-8-0-0-1-0-0-4100-0-0-1-0-0-0-0-0-0-0-0;ip=0;lng=1;anim=1");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
System.Threading.Thread.Sleep(10);
Application.DoEvents();
}
File.WriteAllText(@"C:\pagesource.txt", webBrowser1.DocumentText);
The page source I got is not what the browser showed. When I modify the code like below:
webBrowser1.Navigate("https://mobile.bet365.com/#type=Coupon;key=1-1-13-33977144-2-8-0-0-1-0-0-4100-0-0-1-0-0-0-0-0-0-0-0;ip=0;lng=1;anim=1");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
System.Threading.Thread.Sleep(10);
Application.DoEvents();
}
MessageBox.Show("Loading completed");
File.WriteAllText(@"C:\pagesource.txt", webBrowser1.DocumentText);
and of course I have to press OK when the dialog is shown. The page source is correct now.
I don't understand how can it be like that. And I just want to get the page source automatically (without any clicks or user actions).