统计结果:
1、CU:最后统计的空间浪费结果是:2282M end time:2010-04-04 11:38:40, 主题: 351641, 帖子: 1432244, 会员: 23633797,创建于2003-2-10
2、化工:最后统计的空间浪费结果是:88M end time:2010-04-05 8:52:40, 主题: 3548, 帖子: 9608, 会员: 19094,创建于2007-2-4
3、人大经济论坛:今日: 1216, 昨日: 11562, 最高日: 16583
, 主题: 585770, 帖子: 4881335, 会员: <b>1721538</b>,创建于2004-5-23
<b>4、起点手机论坛,http://www.dimboy.cn/index.php,</b>
今日: 1687, 昨日: 8143, 会员: 44822
<b>5、我要玩手机论坛,http://bbs.512530.com/512530.php,</b>今日: 2201, 昨日: 12656, 会员: 4048683
<b></b>
第一版:[2010-3-31]
<?php
$url = "http://linux.chinaunix.net/bbs/thread-1128442-1-1.html";
$ch = curl_init();
$timeout = 5;
$sum = 0;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
$path = '/tmp';
$p = opendir($path);
if(is_dir($path)){
chdir($path);
echo scandir($p);
$ereg = '.*';
ereg($ereg,$contents,$outcome);
print_r($outcome);
// foreach($outcome as $string)
// echo $string.'
';
//$sum += strlen($string);
file_put_contents(web,$sum);
}else
echo "$path is not dir";
closedir($path);
?>
第二版:[2010-4-1]
<?php
define("CU","http://linux.chinaunix.net/bbs/forum-64-");
// $url = "http://linux.chinaunix.net/bbs/thread-1128442-1-1.html";
//判断网页链接是否已经到头[未完成!]
function isLinkEnd($url1,$url2){
$page1 = file_get_contents($url1);
$page2 = file_get_contents($url2);
$startword = '';
$endword = '';
$startpos1 = strpos($page1,$startword);
$endpos1 = strpos($page1,$endword);
$startpos2 = strpos($page2,$startword);
$endpos2 = strpos($page2,$endword);
$result1 = strstr($page1,$startpos1+strlen($startword),$endpos1-$startpos1-$strlen($startword));
$result2 = strstr($page2,$startpos2+strlen($startword),$endpos2-$startpos1-$strlen($startword));
return ($result1 == $result2?0:1);
}
//自动抽取chinaunix.net上含有回复下载的所有链接,保存为数组返回[已完成!]
function linksOf(){
$page = 1;
$thisurl = CU."$page".'.html';
while( $page $links1[] = $thisurl;
$page++;
$thisurl = CU."$page".'.html';
}
return $links1;
//自动检查所有链接的分页页面地址,保存为数组返回[已完成!]
function linksOfPart($links1){
foreach($links1 as $linksBefore){
$contents = file($linksBefore);
//判断网页链接是否已经到头[已完成!]
function isLinkEnd($url1,$url2){
$page1 = file_get_contents($url1);
$page2 = file_get_contents($url2);
$startword = '';
$endword = '';
$startpos1 = strpos($page1,$startword);
$endpos1 = strpos($page1,$endword);
$startpos2 = strpos($page2,$startword);
$endpos2 = strpos($page2,$endword);
$result1 = substr($page1,$startpos1+strlen($startword),$endpos1-$startpos1-strlen($startword));
$result2 = substr($page2,$startpos2+strlen($startword),$endpos2-$startpos1-strlen($startword));
//返回0说明到头,返回1尚未到头
return ($result1 == $result2?0:1);
$page = 1;
$thisurl = CU."$page".'.html';
while( $page $links1[] = $thisurl;
$page++;
$thisurl = CU."$page".'.html';
}
return $links1;
foreach($links1 as $linksBefore){
$contents = file($linksBefore);
这一版本中,自动截取CU下载版块页面,统计空间浪费功能已经实现,但程序运行速度很慢,有待改进。
出现错误:
开始时间:2010-04-02 09:37:19
<b>Notice</b>: Undefined variable: sum in <b>/var/www/html/lk.php</b>
on line <b>94</b>
<b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>/var/www/html/lk.php</b>
on line <b>75</b>
进一步改进:
define("CU","http://linux.chinaunix.net/bbs/forum-64-");
define("CU_F","http://linux.chinaunix.net/bbs/thread-");
准备再次改进:
直接抓取baidu.com的结果,"site:xxx.com 本帖隐藏的内容需要回复才可以浏览"。
再进行分析,统计数量。
选取的网站有:
1、www.chinaunix.net -> 1000
2、http://bbs.chemdown.cn -> 290
3、http://www.kaoyansky.cn -> 242
4、http://www.pinggu.org 人大经济论坛 -> 932
5、http://www.tianya.cn 天涯社区 -> 1080
6、bbs.duowan.com 多玩游戏论坛 -> 80400 -> 主题: 3516513, 帖子: 79036761, 会员: 8861576 -> 2005-6-29
<b>7、sohu.com 搜狐网 -> </b>9,490
8、sina.com.cn 新浪网 -> 29100
9、mop.com 猫扑 -> 155
$endword = '';
$startpos1 = strpos($page1,$startword);
$endpos1 = strpos($page1,$endword);
$startpos2 = strpos($page2,$startword);
$endpos2 = strpos($page2,$endword);
$result1 = substr($page1,$startpos1+strlen($startword),$endpos1-$startpos1-strlen($startword));
$result2 = substr($page2,$startpos2+strlen($startword),$endpos2-$startpos1-strlen($startword));
//返回0说明到头,返回1尚未到头
return ($result1 == $result2?0:1);
function linksOf($thisurl,$pagetotal){
while( $page $links1[] = $thisurl."$page".'.html';
$flag = 0;
while(count($contents = file($linksBefore)) == 0){
$flag++;
if($flag > 3)break;
}
if($flag > 3)continue;
阅读(1470) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。
Copyright 2001-2010 ChinaUnix.net All Rights Reserved 北京皓辰网域网络信息技术有限公司. 版权所有
感谢所有关心和支持过ChinaUnix的朋友们
京ICP证041476号 京ICP证060528号