我被要求从页面中抓取某行,但似乎该站点已阻止 CURL 请求?
有问题的网站是http://www.habbo.com/home/Intricat
我尝试更改 UserAgent 以查看他们是否阻止了它,但它似乎没有起到作用。
我正在使用的代码如下:
<?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 请求,我可以从该页面获取一行代码的任何想法?
编辑:在通过我的服务器运行 curl -i 时,该站点似乎首先设置了一个 cookie?