- <?php
- /* access_url.php */
- define(SUM, 1000); //需要访问的次数
- define(L_TIME, 1000); //强制脚本执行的时间
- define(S_TIME, 1); //每次访问之间休眠的时间
- $url = "<a href="http://www.xxx.com/Article/GetHits.asp?ArticleID=759">http://www.xxx.com/Article/GetHits.asp?ArticleID=759"; //需要访问的地址
- set_time_limit(L_TIME);
- //访问指定URL函数knowsky.com
- 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<p> </p>\\n";
- }
- unset($file);
- }
- }
- //进行测试
- for ($i=0; $i<SUM; $i++) {
- access_url($url);
- sleep(S_TIME);
- }
- ?>
- //该片段来自于http://www.codesnippet.cn/detail/160120131679.html
来源: http://www.codesnippet.cn/detail/160120131679.html