您好,欢迎访问一九零五行业门户网

利用curl,正则表达式做的一个php蜘蛛抓取器

凤网fcms内容管理系统
get.php 抓取框架,对网页内容的分析处理并进行相关替换
std.php 通用正则
news_67_com.php 对http://news.67.com 的抓取分析器
先抓列表,再抓内容页。
还欠缺监控,统计,错误处理功能。个人觉得还是比较好玩。 '中国娱乐网', 'domain' => 'news.67.com', 'dirname' => '目录名称,用于匹配基于目录不同的正文', 'gettype' => 'default', //获取主文件 'creg' => '/(?si)(.*?)\/', 'code' => 'utf-8', 'sub' => '获取子目录正则', 'content' => 'tag1', 'img_upload'=> array('tag1' => ''), //下一页 'reg_next' => '/(?is)下一页\>\>/', 'key0' => '/(?is)/', 'key0_ap' => array(array(',', '|'), ' '), 'tag0' => '/(?is)([^]*?)/', 'tag0_arp' => array( array( '/(?is)\(组图\)/', '/(?is)\(图\)/', '/(?is)\(图\.\./', '/(?is)\(组图\.\./', '/(?is)\./', '/(?is)(《|》)/', ), array( '', '', '', '', '', '', ) ), 'tag1' => '/(?is)(.*?)/', 'tag1_brp' => array( array( '/(?is)(.*?)/', '/(?is)\(.*?\)/', '/(?is)\s*.*?(.*?)\s*/', '/(?is)\s*\s*/',
'/(?is)\s*\s*/',
'/(?is) /', '/(?is)
/', '/(?is)\s*\s*/',
'/(?is)\s*\s*/',
'/(?is)\s*\s*/', '/(?is)\s*\s*/', '/(?is)\s*\s*/',
), array( '', '', '
', '', '
', '', '', '
', '
', '
', '
', ''
), ), 'tag1_arp' => array( array( '/(?is) /',
'/(?is)/' ), array( '', '' ), ), 'strip' => array('tag1' => ''), 'tag2' => '/(?is)导读:\s*(.*?)\s*/', 'tag2_arp' => array( array( '/(?is) /' ), array( '' ), ), 'tag3' => '/(?is)(中国娱乐网)/', 'tag4' => '/(?is)日期:(\d+-\d+-\d+ \d+:\d+:\d+).*?/',);$map = array( 'tag' => 'key0', 'title' => 'tag0', 'content' => 'tag1', 'summary' => 'tag2', 'source' => 'tag3', 'pub_date' => 'tag4',);$site_list = array( 'aname' => '中国娱乐网', 'domain' => 'www.67.com', 'gettype' => 'default', 'creg' => '/(?si)(.*?)/', 'code' => 'gbk', 'reg_next' => '/(?si)下一页/', //链接 'tag0' => '/(?is).*?[^]*?.*?/', //标题 'tag1' => '/(?is).*?([^]*?).*?/', 'tag1_arp' => array( array( '/(?is)\(组图\)/', '/(?is)\(图\)/', '/(?is)\(图\.\./', '/(?is)\(组图\.\./', '/(?is)\./', '/(?is)(《|》)/', ), array( '', '', '', '', '', '', ) ),);$list_map = array( 'url' => 'tag0', 'title' => 'tag1',);$site_list_sub = array();
复制代码
'[0-9a-za-z\.\:\-\/%_#;&]+', 'img' => '/(?is)/',);
复制代码
parse(file_get_contents(http://tuku.ent.china.com/fun/html/2011-08-23/181703.xml));echo \n\n\n ===================\n;echo $c['field']['tag1'][0];echo \n\n\n ===================\n;var_dump($c);exit();//列表测试$obj = new fchtmlparse($site_list);$c = $obj->parse(file_get_contents(http://tuku.ent.china.com/fun/html/3569_1.html));var_dump($c);exit();/*$obj = new fchtmlget($site);$c = $obj->getpage('http://star.pclady.com.cn/entertainment/ss/1106/703240.html');var_dump($c);$obj = new fchtmlget($site);$c = $obj->getpage('http://star.pclady.com.cn/entertainment/ss/1106/703240.html');var_dump($c);$obj = new fchtmlparse($site);$img_obj = new fchtmlimgupload($site);$data = file_get_contents(e:/b.html);$c = $obj->parse($data);$ic = $img_obj->upload($c['tag']['tag1'][0]);var_dump($ic);$data = file_get_contents(e:/a.html);$c = $obj->parse($data);$ic = $img_obj->upload($c['tag']['tag1'][0]);var_dump($ic); *///var_dump($c['tag']['tag1']);
复制代码
'中华网娱乐图库', 'domain' => 'tuku.ent.china.com', 'dirname' => '目录名称,用于匹配基于目录不同的正文', 'gettype' => 'default', //获取主文件 'creg' => '/(?si)(.*?)/', 'code' => 'utf-8', 'sub' => '获取子目录正则', 'content' => 'tag1', 'img_upload'=> array('tag1' => ''), //下一页 'reg_next' => '/(?is)下一页/', 'key0' => '/(?is)/', 'key0_ap' => array(array(',', '|'), ' '), 'tag0' => '/(?is)title=([^]*?)/', 'tag0_arp' => array( array( '/(?is)\(图\)/', '/(?is)\/', '/(?is)独家:/', '/(?is)独家:/', '/(?is)(《|》)/', ), array( '', '', '', '', '', ) ), 'tag1' => '/(?is)(.*?)/', 'tag1_brp' => array( array( '/(?is)\s*\s*/' ), array( '
$1
$3
' ) ), 'tag1_arp' => array( array( '/(?is)([^]*?)/',
'/(?is)\<br\/\>/', ), array( '$1
', '', ) ), 'strip' => array('tag1' => ''), //网名 'tag3' => '/(?is)([^]*?)/', 'tag4' => '/(?is)(中华网)/');$map = array( 'tag' => 'key0', 'title' => 'tag0', 'content' => 'tag1', 'author' => 'tag3', 'source' => 'tag4');$site_list = array( 'aname' => '中华网娱乐图库', 'domain' => 'tuku.ent.china.com', 'gettype' => 'default', 'creg' => '/(?si)(.*?)/', 'code' => 'utf-8', 'reg_next' => '/(?si)下一页/', //链接 'tag0' => '/(?is).*?[^]*?/', 'tag0_brp' => array( array( '/(?is)\.htm/', ), array( '.xml' ) ), //标题 'tag1' => '/(?is).*?([^]*?)/', 'tag1_arp' => array( array( '/(?is)\(图\)/', '/(?is)\/', '/(?is)独家:/', '/(?is)独家:/', '/(?is)(《|》)/', ), array( '', '', '', '', '', ) ),);$list_map = array( 'url' => 'tag0', 'title' => 'tag1',);$site_list_sub = array();
复制代码
其它类似信息

推荐信息