[PHP] 纯文本查看 复制代码 <?php
/**
* [url=home.php?mod=space&uid=686208]@AuThor[/url] Bob
* Date: 2019/12/8
* [url=home.php?mod=space&uid=621973]@Email[/url] [email]bob@bobcoder.cc[/email]
* [url=home.php?mod=space&uid=406162]@site[/url] https://www.bobcoder.cc/
*/
class Test{
function curl_get($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace(PHP_EOL, '', $url));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$output = curl_exec($ch);
if ($output === FALSE) {
echo "cURL Error: " . curl_error($ch) . "<br>";
} else {
$info = curl_getinfo($ch);
echo '获取 '. $info['url'] . ' 耗时'. $info['total_time'] . '秒' . "<br>";
}
curl_close($ch);
}
function get_url(){
$myfile = fopen("urls.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
$url = fgets($myfile);
$this->curl_get($url);
}
fclose($myfile);
}
}
$test = new Test();
$test->get_url();
|