我被要求从页面抓取某一行,但看起来该网站阻止了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