简体   繁体   English

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

[英]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.

相关问题 我如何屏幕抓取由 javascript 生成的 html 页面 - How do i Screen scrape html page generated by javascript 如何获取完整的数据,包括2个表和2个关联表? - How do I get the full data, including 2 tables and 2 associative tables? 如何将由AngularJs动态生成的HTML页面导出为PDF? - How do I export my HTML page which is dynamically generated by AngularJs as PDF? 如何从未经检查的异常中恢复? - How do I recover from an unchecked exception? 如何根据SessionID恢复会话? - How do I recover a Session based on the SessionID? 如何在c#中查看对服务引用的传入响应的完整SOAP响应(包括标头)? - How do I view the full SOAP response (including header) on incoming responses to a Service Reference in c#? 如何在C#中评估Javascript? (需要获取网页的所有链接,包括java脚本生成的链接) - How to evaluate Javascript within C#? (need to get all links for a web page, including java-script generated ones) 如何将我的Javascript发布到页面上? - How do I post my Javascript to a page? 如何通过C#或Windows格式的网页JavaScript获取动态生成的HTML? - How to get dynamically generated HTML by JavaScript of web page in C# or Windows forms? 如何从套接字错误中恢复? (10040) - How do I recover from a socket error? (10040)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM