在C#中检索网页的TOTAL内容 [英] retrieve the TOTAL contents of a webpage in c#

查看:62
本文介绍了在C#中检索网页的TOTAL内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,eBody,
我正在用C#开发一个应用程序,当浏览器完全加载时,该应用程序需要获取网页的html内容.

如果我尝试使用httpwebrequest和httpwebresponse它为我提供了所需网页的内容,但是内容不完整.我的意思是,它给了我网页的内容,但没有浏览器缓存中的内容.

这是我用来检索内容的代码:

公用字符串GetWebText(字符串url)
{
HttpWebRequest request =(HttpWebRequest)HttpWebRequest .Create(url);
request.UserAgent ="A .NET Web爬网程序";

WebResponse响应= request.GetResponse();

流流= response.GetResponseStream();

StreamReader reader = new StreamReader(stream);
string htmlText = reader.ReadToEnd();
返回htmlText;
}

您可以比较此代码的输出和实际网页的HTML代码是否相同.

请帮助我,这真的让我很烦!!

hello eBody,
i am developing an application program in C# in which need to get the html content of a webpage when is totally loaded in the browser.

if i try httpwebrequest and httpwebresponse it gives me the contents of the required web page, but the content is incomplete. i mean the it gives me the content of web page but without the contents that are in browser cache.

this is the code i used to retrieve the content:

  public string GetWebText(string url)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.UserAgent = "A .NET Web Crawler";

            WebResponse response = request.GetResponse();

            Stream stream = response.GetResponseStream();

            StreamReader reader = new StreamReader(stream);
            string htmlText = reader.ReadToEnd();         
            return htmlText;
        }

you can compare the output of this code and the HTML code of actual web page it is not the same. there are many things that are absent.!!!

please help me it is really troubling me!!!

推荐答案

请帮助我!!!


这篇关于在C#中检索网页的TOTAL内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆