我正在尝试连接到一个网站,为此,我需要一个具有(启用)JavaScript的“浏览器”,否则服务器将拒绝该连接(在HTML文件中,诸如“ ...启用JavaScript以查看完整页面” ...”)。有人知道如何激活JavaScript吗?
void connect (string url){
WebBrowser wb = new WebBrowser();
//this enables JavaScript?
wb.ObjectForScripting = true;
wb.Navigate(new Uri(url));
//I know this could be an endless while
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
}
HtmlDocument doc = wb.Document;
Console.Write(wb.DocumentText);
}