[英]How do I recover the full html of a page, including what is generated by javascript
How do I recover the full html of a page, including what is generated by javascript. 如何恢复页面的完整html,包括javascript生成的内容。 The problem is that I want to access the contents of the select tag, but the page but it is coming empty, this probably being generated dynamically. 问题是我想访问select标记的内容,但是页面却空了,这可能是动态生成的。 Please I'm about to give up! 请我要放弃! I just posted a piece of code because this very large, if I find it necessary to put the whole code. 我刚刚发布了一段代码,因为如果我觉得有必要放入整个代码,这会很大。
res = (HttpWebResponse)req.GetResponse();
res.Cookies = req.CookieContainer.GetCookies(req.RequestUri);
cookieContainer.Add(res.Cookies);
sr = new StreamReader(res.GetResponseStream());
getHtml = sr.ReadToEnd();
viewstate = rxViewstate.Match(getHtml).Groups[1].Value;
EventValdidation = rxEventValidation.Match(getHtml).Groups[1].Value;
viewstate = HttpUtility.UrlEncode(viewstate);
EventValdidation = HttpUtility.UrlEncode(EventValdidation);
//Here I should take the contents of the select tag.
getHtml = rxDropDownMenu.Match(getHtml).Groups[2].Value;
You can't just do this with HttpWebRequest
, all that does is download the raw HTML and non of the linked JavaScript files. 您不能只使用HttpWebRequest
执行此操作,而是下载原始HTML和非链接的JavaScript文件。
It also wouldn't run the JavaScript or give you any kind of DOM to inspect. 它也不会运行JavaScript或提供任何类型的DOM进行检查。
You'd really need to use WebBrowser
or perhaps something like Awesomium . 您确实需要使用WebBrowser
或类似Awesomium的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.