[PHP]使用file_get_content
来源:互联网 发布:js比较字符串 编辑:程序博客网 时间:2024/05/29 18:41
file_get_contents( path , include_path , context , start , max_length)
<?php$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" . "Connection: keep-alive\r\n" . "Cookie: mzys_is_frist_access=1; PHPSESSID=4kacoqfe4ae33km3h0l2imjfd6\r\n" . "Host: http://1212.ip138.com/ic.asp\r\n" . "Referer: http://1212.ip138.com/ic.asp\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 ), 'content' => http_build_query($post, '', '&'),);$context = stream_context_create($hdrs);//方式1echo file_get_contents('http://1212.ip138.com/ic.asp', 0, $context);print_r($http_response_header); // 显示返回的头信息 //方式2// $fp = fopen("http://1212.ip138.com/ic.asp", 'r', false, $context);// fpassthru($fp);// fclose($fp);
失败重试
$cnt=0;while($cnt < 3 && ($str=@file_get_contents('http...'))===FALSE) $cnt++;
原文
阅读全文
0 0
- [PHP]使用file_get_content
- PHP file_get_content或者curl不能使用原因
- php中curl、fsocket、file_get_content三个函数的使用比较
- php中curl、fsocket、file_get_content三个函数的使用比较
- PHP请求http(file_get_content)
- PHP发送POST请求的三种方式 分别使用curl file_get_content fsocket 来实现post提交数据
- PHP发送POST请求的三种方式 分别使用curl file_get_content fsocket 来实现post提交数据
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- 关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)
- PHP http(file_get_content) GET与POST请求方式
- php file_get_content(URL) 执行URL,获取返回结果集
- PHP http(file_get_content) GET与POST请求方式
- 在PHP代码中处理JSON 格式的字符串【或用file_get_content得到的数据】
- PHP file_get_content在远程通信之前的准备,服务器中json_decode解析详解
- php http post 方式有curl 、 file_get_content 、 fsocket ,来post提交数据
- file_get_content 模拟POST数据
- readfile().file().file_get_content()去别!
- SSH整合Ajax实现多屏同步弹幕效果
- 浅析Tomcat中Servlet的运行原理
- 题目263-精 挑 细 选
- Spring五个事务隔离级别和七个事务传播行为
- 归并排序
- [PHP]使用file_get_content
- hdu6092 Rikka with Subset (反向背包)
- API
- 慕课网《Python遇见数据采集》学习过程笔记【1】(这个视频不适合我,终断)
- [dp][二分答案]最大正方形
- 关于 java.toString() ,(String),String.valueOf的区别
- B-,B+,B*数小集合
- 自定义轻量级android控件注解工具--金剪刀(自己命名的)(大家都在用)
- pm2相关命令