我被要求從頁面抓取某一行,但看起來該網站阻止了CURL請求?從阻止CURL的頁面抓取HTML
有問題的網站是http://www.habbo.com/home/Intricat
我試圖改變用戶代理,看看他們是否被阻斷,但它似乎沒有這樣的伎倆。
我使用的代碼如下:
<?php
$curl_handle=curl_init();
//This is the URL you would like the content grabbed from
curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($curl_handle,CURLOPT_URL,'http://www.habbo.com/home/Intricat');
//This is the amount of time in seconds until it times out, this is useful if the server you are requesting data from is down. This way you can offer a "sorry page"
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
//This Keeps everything running smoothly
curl_close($curl_handle);
// Change the message bellow as you wish, please keep in mind you must have your message within the " " Quotes.
if (empty($buffer))
{
print "Sorry, It seems our weather resources are currently unavailable, please check back later.";
}
else
{
print $buffer;
}
?>
的另一種方式我可以抓住的代碼,如果他們已經封鎖捲曲請求該頁面線任何想法?
編輯:在運行curl -i通過我的服務器,它顯示該網站首先設置cookie?
嘗試使用代理並設置推薦鏈接 – Waygood
*「我們的天氣資源」*? - 我敢肯定你的意思是habbo.com的天氣資源,對吧? – hakre
這只是一個隨機站點的代碼。忽略該部分:P – Tenatious