如何获得某个网页的当前HTML代码(非源代码)是当前html代码 而不是源代码因为html页面加载后,可能通过javascript修改过一些东西,所以与源代码不同,再次说明下,我是想得到当前的html代码

解决方案 »

  1.   

    通过Google浏览器可以的,或者使用Webbrowser结合 JS,应该可以的
      

  2.   

    我是想把里面的http代码引用到程序里
      

  3.   

      HttpWebRequest webRequest;
            CookieCollection mycookie = new CookieCollection();
            CookieContainer cookies = new CookieContainer(); /// <summary>
                    /// 获取页面源文件
                    /// </summary>
                    /// <param name="url"></param>
                    /// <returns></returns>
                    public string getUrl(string url)
                    {
                        try
                        {
                            webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
                            webRequest.CookieContainer = new CookieContainer();
                            webRequest.CookieContainer.Add(mycookie);
                            webRequest.Method = "GET";
                            webRequest.Timeout = 10000;//连接时间10秒超时
                            webRequest.ContentType = "application/x-www-form-urlencoded";
                            webRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*";
                            webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; EmbeddedWB 14.52 from: http://www.baidu.com/ EmbeddedWB 14.52; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
                            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
                            mycookie.Add(response.Cookies);
                            cookies.Add(mycookie);
                            StreamReader sr2 = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));
                            string text2 = sr2.ReadToEnd();
                            return text2;
                        }
                        catch (System.Exception ex)
                        {
                            return "";
                        }
                    }
      

  4.   

    webbrowser 好多属性,可以说具体点吗?不知道是我没有说清楚还是都是瞎混分的,貌似只有小贝明白我的意思.
    (我感觉我说的很清楚了,强调了N遍,我不是要源代码)
      

  5.   

    你试过没有啊..
    这那个就是获取当前页面html代码的~~
    你把当前页面的地址传进去返回出来的就是当前html~~~
      

  6.   

    webBrowser用法:IHTMLWindow2 login = (mshtml.IHTMLWindow2)webBrowser1.Document.Window.DomWindow;login 这个也是当前html下面是执行里面的js:login.execScript("js", "javascript");
      

  7.   

    在html中点击右键,菜单里的 查看源文件