的file_get_contents不会对工作的一些网址的
问题描述:
我想用的file_get_contents的file_get_contents不会对工作的一些网址的
$text = @file_get_contents("http://www.kalbam.lt/?feed=rss2");
得到一个RRS饲料,但我不知道为什么我没有得到这个网址(PS东西。与其他RSS供稿它作品)。 allow_url_open处于打开状态。 任何想法?
答
某些服务可以简单地检查请求是来自脚本还是来自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来检索数据。
+0
也许我将不得不做这样的事情。奇怪的情况:P。我会试试这个。 –
+0
好吧,我发现如何去做:) https://*.com/questions/2107759/php-file-get-contents-and-setting-request-headers –
也许删除'@'并检查你的'error.log'?你有'error_reporting'设置? –
阅读[this](https://*.com/questions/26631272/php-file-get-contents-does-not-work-for-some-urls)。 –
错误报告设置为E_ALL –