curl 相关知识
来源:互联网 发布:stc12单片机最小系统 编辑:程序博客网 时间:2024/05/22 09:06
$ch = curl_init();
# 设定url和把结果返回,是否返回头部
curl_setopt($ch, CURLOPT_URL, 'http://www.baidu.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->ch, CURLOPT_HEADER, 1);
# cookie文件设定
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookie_file);
# 额外头部
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0'));
# 设定post
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring);
# 连接、执行过期时间
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 5);
# 是否跟随301 302
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->ch, CURLOPT_MAXREDIRS, 10);
# refer
curl_setopt($this->ch, CURLOPT_REFERER, $refer);
# http版本和端口重用设置
curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($this->ch, CURLOPT_FORBID_REUSE, 1);
# 支持https
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
# 执行
curl_setopt($this->ch, CURLOPT_NOSIGNAL, 1);
$response = curl_exec($ch);
if(curl_errno($ch)){
curl_error($ch);
exit();
}
curl_close($ch);
# 设定url和把结果返回,是否返回头部
curl_setopt($ch, CURLOPT_URL, 'http://www.baidu.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->ch, CURLOPT_HEADER, 1);
# cookie文件设定
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookie_file);
# 额外头部
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0'));
# 设定post
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring);
# 连接、执行过期时间
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 5);
# 是否跟随301 302
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->ch, CURLOPT_MAXREDIRS, 10);
# refer
curl_setopt($this->ch, CURLOPT_REFERER, $refer);
# http版本和端口重用设置
curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($this->ch, CURLOPT_FORBID_REUSE, 1);
# 支持https
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
# 执行
curl_setopt($this->ch, CURLOPT_NOSIGNAL, 1);
$response = curl_exec($ch);
if(curl_errno($ch)){
curl_error($ch);
exit();
}
curl_close($ch);
- curl 相关知识
- curl相关知识
- CURL知识
- curl相关
- curl 相关资料总结
- curl相关操作
- Curl 相关参数用法
- php curl 相关链接 收藏
- curl入门知识之配置你的curl运行环境
- curl入门知识之POST数据
- curl入门知识之抓取二进制数据
- 基于PHP的curl的知识小结
- 微信之CURL,curl相关的知识点
- 相关reactjs的相关知识
- OPC的相关知识
- ActiveX控件相关知识~
- JDBC的相关知识
- 事务的相关知识
- BSP相关概念
- 那些年我准备的cfa
- 串口开发 打印机 读卡器 遇到的问题
- Documentation/networking/ipv6.txt
- 【android开发】手机应用管理器的实现之实现popupWindow类对话框(二)
- curl 相关知识
- 论道——工厂模式与装饰模式的融合
- python中使用MYSQL
- sip eXosip_event结构体中变量eXosip_event_type_t type是怎么产生的?
- 使用Activity Logging监测Domino数据库的活动状况
- Oracle 11g r2分析函数新特性(一)分析函数NTH_VALUE
- CF 359C Prime Number(数论)
- 有源汇上下界最大流 ZOJ 3229 代码
- 代码网站