define(SUM, 500); //需要访问的次数 define(L_TIME, 1000); //强制脚本执行的时间 define(S_TIME, 1); //每次访问之间休眠的时间 set_time_limit(L_TIME);
$url = 'http://pic.news.sohu.com/912231/912232/svip-group-158097.shtml#g=158097&p=1095471';//$url = 'http://vote.biz.itc.cn/answer.jhtm?voteId=83&listAnswer[0].questionId=230&listAnswer[0].checkitemId=1026&subType=3&subId=158073&r=1255069766652&0.4522222890261792';
//进行测试 for ($i=0; $i<SUM; $i++) { access_url($url); sleep(S_TIME); }
//访问指定URL函数 function access_url($url) { if ($url=='') return false; $fp = fopen($url, 'r') or exit('Open url faild!'); if ($fp) { while (!feof($fp)) { $file = fgets($fp); //echo $file."/n"; } unset($file); } }