實施例: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