CURL使用示例之数据采集
来源:互联网 发布:网络会计兼职 编辑:程序博客网 时间:2024/05/17 15:37
</pre><pre name="code" class="php"><?php $ch = curl_init();//初始化curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie:jsessionid=410D5C5A133CB3B00D308F42A106B713"));//发送头信息,如果远程服务器需要session,可以用这种方式伪造curl_setopt($ch, CURLOPT_URL, "http://www.jtyhjy.com/sts/initPage_initQuestionPageForKnowledge.action");//请求地址curl_setopt($ch, CURLOPT_POSTFIELDS, array('disciplineCode'=>'1','disciplineId'=>'20','disciplineType'=>'2'));//POST的数据curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//如果设置为true,cure_exec()将以文件流返回,而不是直接输出到浏览器$data = curl_exec($ch);//返回json格式的字符串$data = json_decode($data,true);//第二个参数缺省的话,json_decode 返回json对象,为true返回数组?>
在curl_exec($ch) 执行后加入 curl_error($ch) 方法可获取 curl 的错误信息,
如果出现错误提示:
Problem (2) in the Chunked-Encoded data!!!
可在curl_exec 前 加入:
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
可解决,具体原理不清楚
0 0
- CURL使用示例之数据采集
- curl采集循环数据
- 使用CURL函数采集
- php 使用CURL函数采集
- curl 使用示例 详细
- CURL使用示例
- php使用curl存取cookie进行登录抓取数据示例
- 使用java采集京东商城行政区划数据示例
- PHP:防止跨域CURL采集数据
- 使用PHP的CURL模拟POST采集开了viewstate的asp.net网页数据
- 使用PHP的CURL模拟POST采集开了viewstate的asp.net网页数据
- curl采集
- curl采集
- CURL采集
- curl采集
- php curl使用小示例
- 使用CURL调用接口[*示例*]
- 使用curl获取数据
- ORA-01795:列表中的最大表达式数为1000采用分页方式的解决方法
- Material Design 中文版(持续更新)
- Python 类的魔力特性之一:property
- InputDispatcher: MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
- Hql语句之uniqueResult()-hql只返回一个结果
- CURL使用示例之数据采集
- wxPython之ImportError: DLL load failed: %1 is not a valid Win32 application.
- LeetCode——Missing Number
- 什么是回调(爱哥出品)
- C++Primer第五版 12.1.1节练习
- Python生成验证码
- Android Bluetooth蓝牙开发(一)
- 3.1.5 窗口的创建
- C++标准库和标准模板库