php 利用curl,正则表达式做的一个php蜘蛛抓取器
利用curl,正则表达式做的一个php蜘蛛抓取器 凤网fcms内容管理系统get.php 抓取框架,对网页内容的分析处理并进行相关替换std.php 通用正则news_67_com.php对http://news.67.com 的抓取分析器先抓列
凤网fcms内容管理系统get.php 抓取框架,对网页内容的分析处理并进行相关替换std.php 通用正则news_67_com.php 对http://news.67.com 的抓取分析器先抓列表,再抓内容页。还欠缺监控,统计,错误处理功能。个人觉得还是比较好玩。
news_67_com.php
<?php include_once dirname(__FILE__) . '/std.php'; $site = array( 'aname' => '中国娱乐网', 'domain' => 'news.67.com', 'dirname' => '目录名称,用于匹配基于目录不同的正文', 'gettype' => 'default', //获取主文件 'creg' => '/(?si)<!--文章 begin-->(.*?)\<\!--文章 end-->/', 'code' => 'utf-8', 'sub' => '获取子目录正则', 'content' => 'tag1', 'img_upload'=> array('tag1' => ''), //下一页 'reg_next' => '/(?is)<a target=\'_self\' href=\'([^\']*?)\'>下一页\>\><\/a>/', 'key0' => '/(?is)<meta name="keywords" content="([^"]*?)".*?\/>/', 'key0_ap' => array(array(',', '|'), ' '), 'tag0' => '/(?is)<h1>([^<^>]*?)<\/h1>/', 'tag0_arp' => array( array( '/(?is)\(组图\)/', '/(?is)\(图\)/', '/(?is)\(图\.\./', '/(?is)\(组图\.\./', '/(?is)\./', '/(?is)(《|》)/', ), array( '', '', '', '', '', '', ) ), 'tag1' => '/(?is)<div class="article" id="divContent">(.*?)<img class="[^"]*?" style="[^"]*?" src="[^"]*?" alt="[^"]*?" border="\d*" \/>/', 'tag1_brp' => array( array( '/(?is)(.*?)/', '/(?is)\(.*?\)/', '/(?is)\s*<p align="center">.*?<img.*?src="([^"]*?)".*?>(.*?)<\/p>\s*/', '/(?is)\s*<p>\s*/', '/(?is)\s*<p align="center">\s*/', '/(?is) /', '/(?is)<br \/>/', '/(?is)\s*<p align="left">\s*/', '/(?is)\s*<p class="f_center" align="center">\s*/', '/(?is)\s*<center>\s*/', '/(?is)\s*<\/center>\s*/', '/(?is)\s*<p class="f_center">\s*/', ), array( '', '', '<p style="text-align: center;"><img src="$1" /></p>', '<p style="text-indent: 24px;">', '<p style="text-align: center;">', '', '', '<p style="text-indent: 24px;">', '<p style="text-align: center;">', '<p style="text-align: center;">', '</p>', '<p style="text-indent: 24px;">' ), ), 'tag1_arp' => array( array( '/(?is)<p style="text-align: center;"> <\/p>/', '/(?is)<strong><\/strong>/' ), array( '', '' ), ), 'strip' => array('tag1' => ''), 'tag2' => '/(?is)<div class="daodu">导读:\s*(.*?)\s*<\/div>/', 'tag2_arp' => array( array( '/(?is) /' ), array( '' ), ), 'tag3' => '/(?is)(中国娱乐网)/', 'tag4' => '/(?is)<div class="artInfo"><span>日期:(\d+-\d+-\d+ \d+:\d+:\d+).*?<\/div>/', ); $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)<div class="gallery_list">(.*?)<div class="nt_cl">/', 'code' => 'gbk', 'reg_next' => '/(?si)<li class="next"><a href="([^"]+?)" target="_self">下一页<\/a><\/li>/', //链接 'tag0' => '/(?is)<div style="height: 30px;">.*?<a target="_blank"\s*href=\'(\w+:\/\/news\.67\.com\/\w+\/\d+\/\d+\/\d+\/\d+\.\w+)\s*\' style="font-size: 14px;">[^<^>]*?<\/a>.*?<\/div>/', //标题 'tag1' => '/(?is)<div style="height: 30px;">.*?<a target="_blank"\s*href=\'\w+:\/\/news\.67\.com\/\w+\/\d+\/\d+\/\d+\/\d+\.\w+\s*\' style="font-size: 14px;">([^<^>]*?)<\/a>.*?<\/div>/', 'tag1_arp' => array( array( '/(?is)\(组图\)/', '/(?is)\(图\)/', '/(?is)\(图\.\./', '/(?is)\(组图\.\./', '/(?is)\./', '/(?is)(《|》)/', ), array( '', '', '', '', '', '', ) ), ); $list_map = array( 'url' => 'tag0', 'title' => 'tag1', ); $site_list_sub = array();
精彩图集
精彩文章