本人想使用c#通过url读取html文件并对其进行查询等操作,请问该如何解决?
谢谢!

解决方案 »

  1.   

    WebClient myWebClient = new WebClient();
                // Download home page data.
                myWebClient.Headers["User-Agent"] =  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
                myWebClient.Headers["Accept-Encoding"] =  "gzip, deflate";
                // Download the Web resource and save it into a data buffer.
                byte[] myDataBuffer = myWebClient.DownloadData("http://searchdns.netcraft.com/?restriction=site+ends+with&host=.sina.com.cn&lookup=wait..&position=limited");            // Display the downloaded data.
                string download = Encoding.ASCII.GetString(myDataBuffer);
      

  2.   

    WebClient 或者WebRequest通过URL可以得到源文件
    然后你解析源文件就可以了
      

  3.   

    html文件在本地,如何读取和解析出其中其他的url信息?
      

  4.   

    WebClient 或者WebRequest效率不是很高 而且工程量也大 不花算啊
      

  5.   

    html文件在本地,如何读取和解析出其中其他的url信息?正则表达式