//用php curl_init函数
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, "$url");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; SV1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//方法用php fsockopen
function ReadPR($link)
{
$fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno) ";
exit(1);
}
else
{
$out = "GET $link HTTP/1.0 ";
$out .= "Host: toolbarqueries.google.com ";
$out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar
2.0.114.9-big; Linux 2.6) ";
$out .= "Connection: Close ";
fwrite($fp, $out);
do{
$line = fgets($fp, 128);
}while ($line !== " ");
$data = fread($fp,8192);
fclose ($fp);
return $data;
}
}