实施例:http://www.whois.net/whois/hotmail.comPHP中使用CURL抓住WHOIS记录
当浏览器中打开,示出了输出。
使用卷曲调用时,它什么都不显示。
怎么了?我想返回整个页面结果,然后使用正则表达式在截止日期:29-Mar-2015 00:00:00行检索数据。
$postfields= null;
$postfields["noneed"] = "";
$queryurl= "http://www.whois.net/whois/hotmail.com";
$results= getUrlContent($postfields, $queryurl);
echo $results;
function getUrlContent($postfields,$api_url)
{
if(!extension_loaded('curl')){die('You need to load/activate the cURL extension (http://www.php.net/cURL).'); }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // set the url to fetch
curl_setopt($ch, CURLOPT_HEADER, 0); // set headers (0 = no headers in result)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // type of transfer (1 = to string)
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // time to wait in seconds
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$content = curl_exec($ch); // make the call
curl_close($ch);
return $content;
}
什么是在这个问题上与正则表达式? – 2010-02-09 04:06:43
删除了正则表达式引用。他们可能希望在从CURL获得结果后使用正则表达式,这可以通过我最后的评论来避免。 – Anthony 2010-02-09 04:12:53
请确保您阅读 - http://www.whois.net/terms-and-conditions,尤其是以下部分:您无权访问或查询WHOIS.NET系统,通过 使用电子程序,量和自动 除非合理必要注册域名或修改现有注册。 – 2011-08-09 20:12:37