zoukankan      html  css  js  c++  java
  • file_get_contents HTTP request failed! Internal Server Error

    使用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);

     

  • 相关阅读:
    汉明距离
    Go_go build 和 go install
    rabbitmq的简单介绍二
    rabbitmq的简单介绍一
    redis的订阅和发布
    python操作redis
    vmware虚拟机开机报附件中的错误的解决办法
    使用twised实现一个EchoServer
    python事件驱动的小例子
    mysql数据库的最基本的命令
  • 原文地址:https://www.cnblogs.com/54sen/p/6732145.html
Copyright © 2011-2022 走看看