file_get_contents对某些网址不起作用

时间:2017-06-30 09:15:28

标签: php xml rss file-get-contents

我想使用file_get_contents

获取rrs feed
$text = @file_get_contents("http://www.kalbam.lt/?feed=rss2");

但是我不知道为什么我从这个网址中得不到任何东西(PS。与其他rss feed它有效)。 allow_url_open已启用。 有什么想法吗?

1 个答案:

答案 0 :(得分:1)

某些服务可以简单地检查请求是来自脚本还是来自Web浏览器。然后他们可以阻止请求。但为什么不创建假标题?!

$header=array('GET /1575051 HTTP/1.1',
'Host: adfoc.us',
'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language:en-US,en;q=0.8',
'Cache-Control:max-age=0',
'Connection:keep-alive',
'Host:adfoc.us',
'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36',
);

然后使用curl来检索数据。

相关问题