日期:2014-05-17  浏览次数:20436 次

ASP.net抓取网页指定内容——怎么抓
这个是抓取了整个页面的内容代码

  HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(TextBox1.Text);
        HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
        Stream stream = webResponse.GetResponseStream();
        StreamReader reader = new StreamReader(stream, System.Text.Encoding.GetEncoding("utf-8"));
        //整个页面内容
        Label1.Text = reader.ReadToEnd();


我希望的是抓取页面某些内容。 只要里面的文字内容和链接就好了。我要插入到数据库。
 <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#EFEFEF">
              <tr bgcolor="#FFFFFF"> 
                <th width="70%" align="center">标题</th>
                <th width="15%" align="center">栏目</th>
                <th width="15%" align="center">上线时间</th>
              </tr>
  
              <tr bgcolor="#FFFFFF"> 
                <td width="70%" align="left"><a href="http://www.ccmtv.cn/bencandy.php?fid=52&id=3102" target="_blank" title='' style="">蔡军教授寄语</a></td>
                <td width="15%" align="center">专家寄语</td>
                <td width="15%" align="center">2013-07-05</td>
              </tr>
              
              <tr bgcolor="#FFFFFF"> 
                <td width="70%" align="left"><a href="http://www.ccmtv.cn/bencandy.php?fid=643&id=2983" target="_blank" title='' style="">蔡三军:对大肠癌肝转移患者 外科医生应始终积极主动</a></td>