public function curlss($url)
{
$curl = curl_init(); // 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, $url); // 设置header
//curl_setopt($curl, CURLOPT_HEADER, 0); // 设置cURL 参数,要求结果(1保存到字符串中)还是(0输出到屏幕上)。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 运行cURL,请求网页 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);// https请求 不验证证书和hosts
$htmls = curl_exec($curl); // 关闭URL请求 curl_close($curl);
return $htmls;
} ----------------------------------------------POST-----------------------------------------------------------------------------------
public function curls($url, $data)
{
$curl = curl_init(); // 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, $url); // 设置header
//curl_setopt($curl, CURLOPT_HEADER, 0); // 设置cURL 参数,要求结果(1保存到字符串中)还是(0输出到屏幕上)。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 运行cURL,请求网页
curl_setopt($curl, CURLOPT_POST, 1);
// post的变量
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);// https请求 不验证证书和hosts
$html = curl_exec($curl); // 关闭URL请求 curl_close($curl);
// var_dump($html);
// exit;
return $html; }

CURL post/get提交的更多相关文章

  1. CURL 模拟http提交

    1:CURL模拟get提交 private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETUR ...

  2. PHP再学习1——cURL表单提交、HTTP请求和响应分析

    1.前言 最近迷恋WEB方面的技术,虽然自己是一个嵌入式工程师,但是我深知若需要把传感器终端的数据推送至“平台”必然会和WEB技术打交道.在工作中发现嵌入式工程师喜欢 二进制形式的协议,例如MODBU ...

  3. php中curl模拟post提交多维数组(转载)

    原文地址:http://www.cnblogs.com/mingaixin/archive/2012/11/09/2763265.html 今天需要用curl模拟post提交参数,请求同事提供的一个接 ...

  4. cURL模拟POST提交数据

    首先,是这个代码: <?php //curl模拟post提交数据$url = "http://127.0.0.1/immoc/output.php";$post_data = ...

  5. 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法

    在php中分别使用curl的post提交数据的方法和get获取网页数据的方法整理分享一下额,具体代码如下: (1)使用php curl获取网页数据的方法: $ch=curl_init(); //设置选 ...

  6. (转载)PHP 下 CURL 通过 POST 提交表单失败的原因之一与解决办法

    (转载)http://blog.renren.com/share/246611432/7511385884 前几天在学习使用 CURL 时遇到一个问题:在 a.php 中以 POST 方式向 b.ph ...

  7. curl之post提交xml

    直接上代码: /** * 以post方式提交xml到对应的接口url * * @param string $xml 需要post的xml数据 * @param string $url url * @p ...

  8. php通过CURL模拟post提交请求

    <?php header("Content-type:text/html;charset=utf-8"); class Test{ public function reque ...

  9. php CURL 模拟 POST 提交数据

    <?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...

  10. php curl vs python提交多维数组+文件

    总结: 1.data数据格式 2.php post 格式无需json_encode(关联数组,所以可以绕弯)  参考:http://bbs.csdn.net/topics/390645553?page ...

随机推荐

  1. 从Unity中的Attribute到AOP(三)

    上一篇我们对系统的Attributes进行了MSIL代码的查看,了解到了其本质就是一个类的构造函数.本章我们将编写自己的Attributes. 首先我们定义书的属性代码,如下: [AttributeU ...

  2. C#学习笔记-工厂模式

    题目:计算器 解析:工厂方法(Factory Method),定义一个用于创建对象的接口,让子类决定实例化哪一个类. 定义运算类: class Operation { ; ; public doubl ...

  3. Oracle02——oracle分页、子查询、集合运算、处理数据、创建和管理表和其他数据库对象

    作者: kent鹏 转载请注明出处: http://www.cnblogs.com/xieyupeng/p/7289451.html --oracle分页(Pageing Query) select ...

  4. Java Web应用集成OSGI

    对OSGI的简单理解 就像Java Web应用程序需要运行在Tomcat.Weblogic这样的容器中一样.程序员开发的OSGI程序包也需要运行在OSGI容器中.目前主流的OSGI容器包括:Apach ...

  5. 2017 Multi-University Training Contest - Team 1 1006&&HDU 6038 Function【DFS+数论】

    Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  6. BZOJ 1411&&Vijos 1544 : [ZJOI2009]硬币游戏【递推,快速幂】

    1411: [ZJOI2009]硬币游戏 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 897  Solved: 394[Submit][Status ...

  7. HDFS(数学题)

    题目连接:http://acm.tju.edu.cn/toj/showp.php?pid=4119 4119.   HDFS Time Limit: 5.0 Seconds   Memory Limi ...

  8. You can Solve a Geometry Problem too(线段求交)

    http://acm.hdu.edu.cn/showproblem.php?pid=1086 You can Solve a Geometry Problem too Time Limit: 2000 ...

  9. c语言_FILE结构体解释及相关操作

    1. 文件和流的关系 C将每个文件简单地作为顺序字节流(如下图).每个文件用文件结束符结束,或者在特定字节数的地方结束,这个特定的字节数可以存储在系统维护的管理数据结构中.当打开文件时,就建立了和文件 ...

  10. 96、python version 3.6 required,which was not fount in the registry(python3.6安装scrapy)

    在安装scrapy时遇到问题 环境:win10(64位), Python3.6(64位) 安装scrapy: 1.安装wheel(安装后,便支持通过wheel文件安装软件) pip3 install ...