PHPʹÓÃfile_get_contentÉèÖÃÍ·ÐÅÏ¢µÄ·½·¨

5年以前  |  阅读数:692 次  |  编程语言:PHP 

±¾ÎÄʵÀý½²ÊoÁËPHPʹÓÃfile_get_contentÉeÖÃÍÐÅÏ¢µÄ½¨¡£ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º

Ö±½ÓÉÏ´uÂe£º


    <?php
    /**
    Accept application/json
    Accept-Encoding gzip, deflate
    Accept-Language zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
    Connection keep-alive
    Cookie mzys_is_frist_access=1; mzys_c_uuid=guest_215cbc0979b5bd2; mzys_access20130610=1; mzys_qz_uuid=d6d4640f93cb7a4; CNZZDATA30040410=cnzz_eid%3D1008690174-1370849811-http%253A%252F%252Fm.120ask.com%26ntime%3D1370855345%26cnzz_a%3D43%26retime%3D1370855484258%26sin%3D%26ltime%3D1370855484258%26rtime%3D0; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6
    Host m.120ask.com
    Referer http://m.120ask.com/health/show?page=2&id;=84882&type;=17
    User-Agent Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0
    X-Requested-With XMLHttpRequest
     */
    $hdrs = array(
      'http' =>array('header' => 
       "Accept: application/json\r\n" .
       "Accept-Encoding: gzip, deflate\r\n" .
       "Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n" .
       "Accept-Encoding: gzip, deflate\r\n" .
       "Connection: keep-alive\r\n" .
       "Cookie: mzys_is_frist_access=1; mzys_c_uuid=guest_215cbc0979b5bd2; mzys_access20130610=1; mzys_qz_uuid=d6d4640f93cb7a4; CNZZDATA30040410=cnzz_eid%3D1008690174-1370849811-http%253A%252F%252Fm.120ask.com%26ntime%3D1370855345%26cnzz_a%3D43%26retime%3D1370855484258%26sin%3D%26ltime%3D1370855484258%26rtime%3D0; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6\r\n" .
       "Host: m.120ask.com\r\n" .
       "Referer: http://m.120ask.com/health/show?page=2&id;=84882&type;=17\r\n" .
       "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0\r\n" .
       "X-Requested-With: XMLHttpRequest",
       'timeout'=>2
      ),
    );
    $context = stream_context_create($hdrs);
    //*½Ê½1
    // $fp = fopen("http://m.120ask.com/health/show?page=2&id;=84882&type;=17", 'r', false, $context);
    // fpassthru($fp);
    // fclose($fp);
    //*½Ê½2
    //echo file_get_contents('http://m.120ask.com/health/show?page=2&id;=84882&type;=17', 0, $context);

¸u¶a¹ØÓÚPHPÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶PHP»u±¾Ói*¨ÈeÃŽ̡̳¡¢¡¶[PHP´iÎoÓeÒi³£´¦Ài½¨×ܽa](http://www.jb51.net/Special/196.htm)¡¼°¡¶php³£Óú¯ÊýÓe¼¼ÇÉ×ܽa¡*

Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例