douniuta4783 2014-02-13 02:43
浏览 24
已采纳

file_get_contents 3小时前工作过 - 现在没有

Three hours ago I was working on my site, then I had a nap, and now my file_get_contents request isn't working.

$Url = sprintf( "http://www.wowhead.com/item=%u?xml", $EntryId );
$Xml = file_get_contents( $Url );    

Display ID for example could be 30987. The url formed: http://www.wowhead.com/item=30987?xml This works in a browser - but in my site I get: failed to open stream: HTTP request failed!.

I don't really get it - because it worked perfectly just 3 hours ago.

Does anyone have any idea? Thanks.

  • 写回答

1条回答 默认 最新

  • dongtu7567 2014-02-13 02:50
    关注

    They way you are reading the HTTP content can be the problem. You are reading it as a file. That does not send proper HTTP headers. Server may refuse to serve the page contents when the request is not formatted properly. Read the contents of the URL using HTTPRequest

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等