我想制作一个脚本来显示网站的反向 ip。为此,我将使用第 3 方网站。所以我的脚本是:
<?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 无法获取此类网页?