簡體   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