比如http://www.baidu.com/
我要获取
<html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><title>百度一下,你就知道      </title><style>body{margin:4px 0}p{margin:0;padding:0}img{border:0}td,p,#u{font-size:12px}#b,#u,#l td,a{font-family:arial}#kw{font:16px Verdana;height:1.78em;padding-top:2px}#b{height:30px;padding-top:4px}#b,#b a{color:#77c}#u{padding-right:10px;line-height:19px;text-align:right;margin:0 0 3px !important;margin:0 0 10px}#sb{height:2em;width:5.6em}#km{height:50px}#l{margin:0 0 5px 15px}#l td{padding-left:107px}p,table{width:650px;border:0}#l td,#sb,#km{font-size:14px}#l a,#l b{margin-right:1.14em}a{color:#00c}a:active{color:#f60}#hp{position:absolute;margin-left:6px}#lg{margin:-26px 0 -44px}#lk{width:auto;line-height:18px;vertical-align:top}#sug{display:none}</style></head>
<body><div id=u><a href=http://passport.baidu.com/?login&tpl=mn>登录</a></div><center><img src=http://www.baidu.com/img/baidu_logo.gif width=270 height=129 usemap="#mp" id=lg><br><br><br><br><table cellpadding=0 cellspacing=0 id=l><tr><td><div id=m><a onclick=s(this) href=http://news.baidu.com>新&nbsp;闻</a><b>网&nbsp;页</b><a onclick=s(this) href=http://tieba.baidu.com>贴&nbsp;吧</a><a onclick=s(this) href=http://zhidao.baidu.com>知&nbsp;道</a><a onclick=s(this) href=http://mp3.baidu.com>MP3</a><a onclick=s(this) href=http://image.baidu.com>图&nbsp;片</a><a onclick=s(this) href=http://video.baidu.com>视&nbsp;频</a></div></td></tr></table>
<table cellpadding=0 cellspacing=0 style="margin-left:15px"><tr valign=top><td style="height:62px;padding-left:92px" nowrap><div style="position:relative"><form name=f action=s><input type=text name=wd id=kw size=42 maxlength=100> <input type=submit value=百度一下 id=sb><div id=sug onselectstart="return false"></div><span id=hp><a href=/gaoji/preferences.html>设置</a><br><a href=/gaoji/advanced.html>高级</a></span></form></div></td></tr></table>
<p id=km><a href=http://hi.baidu.com>空间</a>&nbsp;&nbsp;<a href=http://www.hao123.com>hao123</a>&nbsp;|&nbsp;<a href=/more/>更多<span style="font-family:宋体">>></span></a></p>
<p style=height:60px><table cellpadding=0 cellspacing=0 id=lk><tr><td></td></tr></table></p>
<p style=height:30px><a onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.baidu.com')" href=http://utility.baidu.com/traf/click.php?id=215&url=http://www.baidu.com>把百度设为主页</a></p><p style=height:14px><a href=http://jingjia.baidu.com>企业推广</a> | <a href=http://top.baidu.com>搜索风云榜</a> | <a href=/home.html>关于百度</a> | <a href=http://ir.baidu.com>About Baidu</a></p><p id=b>&copy;2009 Baidu <a href=http://www.baidu.com/duty/>使用百度前必读</a> <a href=http://www.miibeian.gov.cn target=_blank>京ICP证030173号</a> <img src=http://gimg.baidu.com/img/gs.gif></p><map name=mp><area shape=rect coords="43,22,227,91" href=http://hi.baidu.com/baidu/ target=_blank title="点此进入 百度空间"></map></center></body>
<script>var w=document.f.wd;function s(o){if(w.value.length>0){var h=o.href;var q=encodeURIComponent(w.value);if(h.indexOf("q=")!=-1){o.href=h.replace(new RegExp("q=[^&$]*"),"q="+q)}else{o.href+="?q="+q}}};(function(){if(new RegExp("q=([^&]+)").test(location.search)){w.value=decodeURIComponent(RegExp.$1)}})();if(navigator.cookieEnabled && /BAIDUID=\w{30}(\w{2})([^;]*)(;|$)/.test(document.cookie) && !/:SU=0/.test(RegExp.$2)){var num = parseInt(RegExp.$1, 16);if(num<250){document.getElementById('kw').setAttribute('autocomplete', 'off');var so=document.createElement('SCRIPT');so.src='http://www.baidu.com/js/bdsug.js?v=1.0.2.0';document.getElementsByTagName('HEAD')[0].appendChild(so);var ti=setInterval(function(){if(!window.baidu){return}else{window.baidu.init();clearInterval(ti)}},10)}if(num>243){var i = document.createElement('INPUT');i.name='tn';i.value='baidutnta'+(num<250?'1':'0');i.type='hidden';document.f.appendChild(i);}}window.onunload=function(){};w.focus();</script></html><!--6dd57d308f299e7f-->

解决方案 »

  1.   


                 WebClient client = new WebClient();
                 string reply = client.DownloadString("http://www.qqview.com");
                Response.Write(reply);
      

  2.   


    string html = new WebClient.DownloadString("http://www.baidu.com/");
      

  3.   


    System.Net.WebClient wc = new System.Net.WebClient();
    string source = wc.DownloadString("http://www.baidu.com");
      

  4.   

    WebClient.DownloadString("http://www.baidu.com/");
    用jquery也可以
    $jquery(url)
      

  5.   

    private string GetStringByUrl(string strUrl)
        {
            WebRequest wrt = WebRequest.Create(strUrl);
            WebResponse wrse = wrt.GetResponse();
            Stream strM = wrse.GetResponseStream();
            StreamReader SR = new StreamReader(strM, Encoding.GetEncoding("gb2312"));
            string strallstrm = SR.ReadToEnd();
            return strallstrm;
        }
      

  6.   

      // 获取网页的HTML内容,指定Encoding
      static string GetHtml(string url, Encoding encoding)
      {
        byte[] buf = new WebClient().DownloadData(url);
        if (encoding != null) return encoding.GetString(buf);
        string html = Encoding.UTF8.GetString(buf);
        encoding = GetEncoding(html);
        if (encoding == null || encoding == Encoding.UTF8) return html;
        return encoding.GetString(buf);
      }
      

  7.   

      // 获取网页的HTML内容,根据网页的charset自动判断Encoding
      static string GetHtml(string url)
      {
        return GetHtml(url, null);
      }  // 获取网页的HTML内容,指定Encoding
      static string GetHtml(string url, Encoding encoding)
      {
        byte[] buf = new WebClient().DownloadData(url);
        if (encoding != null) return encoding.GetString(buf);
        string html = Encoding.UTF8.GetString(buf);
        encoding = GetEncoding(html);
        if (encoding == null || encoding == Encoding.UTF8) return html;
        return encoding.GetString(buf);
      }  // 根据网页的HTML内容提取网页的Encoding
      static Encoding GetEncoding(string html)
      {
        string pattern = @"(?i)\bcharset=(?<charset>[-a-zA-Z_0-9]+)";
        string charset = Regex.Match(html, pattern).Groups["charset"].Value;
        try { return Encoding.GetEncoding(charset); }
        catch (ArgumentException) { return null; }
      }
      

  8.   

    给你个数据抓取的类吧
    http://web46624.s25.webcontrol.cn/webpage.txt