我想创建一个脚本,显示一个站点的反向ip。为此,我将使用第三方网站。所以我的脚本是:
<?php
$ip='http://viewdns.info/reverseip/?host=barnesandnoble.com';
$useragent='Mozilla/5.0 (BlackBerry; U; BlackBerry 9700; pt) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.546 Mobile Safari/534.8+';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ip);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
$file = curl_exec($ch);
echo ($file); //this is for testing that files are getting or not
?>
但这不会返回任何东西。我的代码错误了吗?或者CURL无法获得这种网页?