使用file_get_contents报错

Severity: Warning
Message: file_get_contents(http://geetest.com:8000/select?gid=bf59a3fe652ece81dfb179219ce5b46e&date=2013-08-09) [function.file-get-contents]: failed to open stream: HTTP request failed! Internal Server Error

遇到这种情况不要慌,我们只要将php默认的user_agent改成Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)进来模拟浏览器即可。

修改方法:

PHP伪造user_agent

   ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');

伪造自后还是不行

  $context = stream_context_create(array('http'=>array('ignore_errors'=>true)));

  $nos = file_get_contents($url, FALSE, $context);

完整栗子:

ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');
$context = stream_context_create(array('http'=>array('ignore_errors'=>true)));
file_get_contents($url, FALSE, $context);

file_get_contents HTTP request failed! Internal Server Error的更多相关文章

  1. OPENTSDB: Request failed: Internal Server Error net.opentsdb.core.IllegalDataException

    今天Opentsdb补传历史数据的时候,出现了如下的错误: Request failed: Internal Server Error net.opentsdb.core.IllegalDataExc ...

  2. PHP如何让apache支持.htaccess 解决Internal Server Error The server …错误

    TP框架  打开 www.newtp.com/index.php/Home/Index/abc出现 如下错误: Internal Server Error The server encountered ...

  3. SquishIt引起的HTTP Error 500.0 - Internal Server Error

    将一个ASP.NET项目从.NET Framework 4.0升级至.NET Framework 4.5之后,访问时出现HTTP Error 500.0 - Internal Server Error ...

  4. 如何让apache支持.htaccess 解决Internal Server Error The server …错误

    如何让apache支持.htaccess 解决Internal Server Error The server …错误 文章来源:小灰博客| 时间:2013-12-25 12:17:08| 作者:Le ...

  5. php Internal Server Error

    Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...

  6. Apache Internal Server Error

    当使用 Apache 作为服务器,使用 cgi 程序接收来自 web 端的访问时,出现如下错误: Internal Server Error The server encountered an int ...

  7. CI当开启URL重写的时候,报错500 Internal Server Error

    Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...

  8. apache Internal Server Error 的几个问题

    Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...

  9. Nagios Apache报Internal Server Error错误的解决方法

    今天配置Nagios的时候遇到了一些麻烦,前面的步骤都一切顺利,nagios运行后,可以看到nagios的主页,但点击左边的菜单时总是提示Internal Server Error错误.错误如下: v ...

随机推荐

  1. SQLServer存储过程实现单条件分页

    SQLServer Procedure Pagination_basic: ALTER PROCEDURE [qiancheng].[Pagination_basic] ( ), --name of ...

  2. 学习HTML5一周的收获1

    HTML5的基本结构 学习了title标签(显示网站名称),link标签(链接文件,可做网页美化) 快捷键:Ctrl+/ 注释 学习[meta标签] 1.charset属性:单独使用,设置文档字符集编 ...

  3. win10如何合并硬盘分区

    好多人都会讲电脑硬盘分成几个不同的区,以方便自己的资料的存储和查找,但不少人不知道如何合并已经分出的硬盘分区.以下是我的经验,与大家分享: 1.   首先,右击“此电脑”,在弹出来的右键菜单这种选择“ ...

  4. Mutillidae在kali linux上的安装

    XAMPP:下载地址(https://www.apachefriends.org/download.html) Mutillidae:下载地址(http://sourceforge.net/proje ...

  5. Fibonacci数列前n项值的输出(运用递归算法)

    1.斐波那契数列: 又称黄金分割数列,指的是这样一个数列:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... 在数学上,斐波纳契数列以如下被以递归的方法 ...

  6. C++数据

    const :常量 ~x == -++x == -(x+1)   二进制数,1变为0,0变为1 ^                               相同为0,不同为1 &      ...

  7. maridb安装审计audit插件

    1.下载插件 https://mariadb.com/kb/en/mariadb-audit- plugin/ 比较新的mariadb版本audit插件直接内嵌在版本里,可以直接安装 INSTALL ...

  8. iwebshop里面传数组且输出

    //php后台 $starttimestr = $arr[0]['forea_time']; $endtimestr = $arr[0]['end_time']; $data['starttime'] ...

  9. windows 安装Beautiful Soup(转)

    Beautiful Soup是一个Python的一个库,主要为一些短周期项目比如屏幕抓取而设计.有三个特性使得它非常强大: 1.Beautiful Soup提供了一些简单的方法和Python术语,用于 ...

  10. 自适应的tab菜单栏

    代码部分: Css代码:*{ margin:0px; padding:0px; font-size:62.5%;}body{ background-color:#FFFFFF;}.zw-test-ti ...