繁体   English   中英

如何恢复页面的完整html,包括javascript生成的内容

[英]How do I recover the full html of a page, including what is generated by javascript

如何恢复页面的完整html,包括javascript生成的内容。 问题是我想访问select标记的内容,但是页面却空了,这可能是动态生成的。 请我要放弃! 我刚刚发布了一段代码,因为如果我觉得有必要放入整个代码,这会很大。

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;

您不能只使用HttpWebRequest执行此操作,而是下载原始HTML和非链接的JavaScript文件。

它也不会运行JavaScript或提供任何类型的DOM进行检查。

您确实需要使用WebBrowser或类似Awesomium的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM