|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
大家都知道,如果自己的页面需要增加PR值,常见的办法就是自己刷新。但是这样太累了。
下面这段程序适合在php命令行模式下运行(unix,win平台都实用)
用之前请修改php.ini的buffer为0,和设定网页地址,这里面有个技巧,你需要fetch的叶面越小越好。
大家可以来试验。不懂得清联系我:qq:
42352331
www.dailwap.com
<?php
//修改php.ini参数(buffer)和设定网页地址。
$filename = "http://www.dailwap.com/1.htm";
set_time_limit(0);
error_reporting(E_ALL);
ini_set("display_errors",1);
/**
* get microtime
*
* @return time,seconds for each unit
*/
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
echo "read started"."<br>"."\n";
/*useragent 判断换行*/
//CLI模式和网页浏览模式
if(isset($_SERVER['HTTP_USER_AGENT']))
{
$wordwrap="<br \>";
}
else
{
$wordwrap="\n";
}
$total = 1000000;
$step = 1000;
$failed = 0;
for($i=1;$i<=$total;$i++)
{//
$filename = "http://www.dailwap.com/1.htm";
if($handle = @fopen($filename, "r"))
{//success
if(($i)%($step)==0)
{
echo "$i pieces of files read.time elapsed ".(getmicrotime()-$time_start).' seconds'.$wordwrap;
echo "failed $failed times".$wordwrap;
echo $wordwrap;
}
fclose($handle);
}
else
{
$failed++;
echo "failed when fetch $i row,all failed $failed times in passed ".(getmicrotime()-$time_start)." seconds".$wordwrap;
}
}
$time_end = getmicrotime();
echo "files all done.time elapsed ".($time_end-$time_start).' seconds'."<br>"."\n";
echo "fetched ".($i/$step)." times"."<br>"."\n";
echo "average ".($time_end-$time_start)/$i."<br>"."\n";
//for console stop
system("pause")."<br>"."\n";
?> |
|