六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 141|回复: 0

采集系统万能正则表达式

[复制链接]

升级  58%

110

主题

110

主题

110

主题

举人

Rank: 3Rank: 3

积分
374
 楼主| 发表于 2013-2-7 20:11:35 | 显示全部楼层 |阅读模式
由于经常要写一些采集的程序,下面的三个函数是采集中的很常用的函数。姑且叫采集系统万能正则表达式吧。全部源码见
http://www.softbk.com/news.asp?id=3564<script type="text/javascript"><!--google_ad_client = "pub-4334685396432654";//468x15, 创建于 07-12-5google_ad_slot = "3722935453";google_ad_width = 468;google_ad_height = 15;//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>    欢迎一起交流

<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;">//获取页面的html源码
 public  string GetHtmlSource(string Url, string charset)
        
{
            
if (charset == "" || charset == null) charset = "gb2312";
            
string text1 = "";
            
try
            
{
                HttpWebRequest request1 
= (HttpWebRequest)WebRequest.Create(Url);
                HttpWebResponse response1 
= (HttpWebResponse)request1.GetResponse();
                Stream stream1 
= response1.GetResponseStream();
                StreamReader reader1 
= new StreamReader(stream1, Encoding.GetEncoding(charset));
                text1 
= reader1.ReadToEnd();
                stream1.Close();
                response1.Close();
            }

            
catch (Exception exception1)
            
{
            }

            
return text1;
        }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表