【问题标题】:file_get_contents failed to open stream only with multiplefile_get_contents 无法打开多个流
【发布时间】:2014-07-04 06:16:33
【问题描述】:

我遇到了问题。我正在编写一个应该使用 file_get_contents 函数的 php 脚本。

而且效果非常好,当我在我的脚本中使用它一次时效果非常好,我没有收到任何错误,但如果我实施更多,那么一旦我得到休闲错误

警告:file_get_contents((ddl"%cge,add`$Cbe&) [function.file-get-contents]: 无法打开流:/home/content/34/9587634/html/ 中没有这样的文件或目录WebSite.Com/userarea123/urlupload.php 第 85 行 过滤后的 HTML:页面标题:Harumi Sushi

这里以我的代码为例

$url1 = "http://www.dogpile.com";
$url2 = "http://www.google.com";

$Test1= file_get_contents($url1);
echo $Test1;

$Test2= file_get_contents($url2);
echo $Test2;

我不确定是什么导致了这个问题

感谢所有帮助 非常感谢

【问题讨论】:

标签: php file-get-contents


【解决方案1】:

是的,这不是多次调用的问题,而是 dogpile.com 的问题。他们可能有某种保护——他们正在检测浏览器并基于此提供不同的内容。尝试使用 curl 库并模拟一些浏览器:

http://www.php.net/manual/en/book.curl.php

【讨论】:

  • 您还可以在 file_get_contents 的上下文中模拟浏览器(设置用户代理标头)
猜你喜欢
  • 2018-01-24
  • 1970-01-01
  • 2020-10-02
  • 2017-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-16
  • 1970-01-01
相关资源
最近更新 更多