博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

远程网页内容抓取

Posted on 2009-07-15 15:14  冷咖啡(子锡)  阅读(148)  评论(0编辑  收藏  举报

using System;
using System.Collections;
using System.Threading;
using System.Data;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

===================================================

try{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strSpiderURL);
                request.Timeout = 300000;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                System.IO.StreamReader srContent = new System.IO.StreamReader(response.GetResponseStream(),System.Text.Encoding.GetEncoding("gb2312"));
                //获取抓取下来的页面内容
                strPage = srContent.ReadToEnd();
                response.Close();
                srContent.Close();
}catch{
  
}