PHP - file_get_contents 系统错误?
我正在尝试从 url 解析 html。我这样做:
$html = file_get_contents($someURL);
echo $html;
但是当我运行该脚本时,页面显示:
UISCGI (software8a-web; software8a-link):
This site is best viewed with Netscape 4.6 or 4.7 or Internet Explorer 5 and greater.
At this time Netscape 6 is not supported for Link usage.
我还尝试了 CURLing url,同时将 IE7 伪装为用户代理。
这里出了什么问题?我在谷歌上找不到这个错误。我该如何克服这个系统错误?
I'm trying to parse the html from a url. I do this:
$html = file_get_contents($someURL);
echo $html;
But when I run that script, the page shows this:
UISCGI (software8a-web; software8a-link):
This site is best viewed with Netscape 4.6 or 4.7 or Internet Explorer 5 and greater.
At this time Netscape 6 is not supported for Link usage.
I also tried CURLing the url, while faking IE7 as the User Agent.
What's going wrong here? I couldn't find this error anywhere with Google. How do I get past this system error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了这样一个地址,伪造用户代理效果很好。也许您的情况下标头的设置是错误的。
简单的例子:(
没有 ini_set() 我得到和你一样的输出)
注意:从 PHP5 开始,file_get_contents() 还允许通过可选的上下文参数设置标头-
I found such an adress, faking of the user-agent works fine. Maybe the setting of the header is wrong in your case.
simple example:
(without the ini_set() I get the same output like you)
Note: From PHP5 on file_get_contents() also allows setting of headers via the optional context-parameter-