https://mp.weixin.qq.com/s/8luqMEd8xt8oJxFLLCU1XA
文章正文
cURL是利用url语法规定传输文件和数据的工具。php中有curl拓展,一般用来实现网络抓取,模拟发送get post请求,文件上传。
在php中建立curl的基本步骤如下:
1 初始化 2 设置选项,包括url 3 执行并获取结果 4 释放curl句柄。
在工作和学习中,我也是时常用的curl。由于在使用curl设置选项时,各种选项比较难以记忆,需要参考,故在此记录下常用的一些例子,以便后来参考。
实例一 : 抓取网页数据(以拉手网开放api为例,也是get请求)
php header("Content-type: text/html; charset=utf-8"); $ch = curl_init();//初始化 /*============开始设置curl各种选项================*/ curl_setopt($ch, CURLOPT_URL, "http://open.lashou.com/opendeals/lashou/city.xml"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec($ch);//执行句柄,获取返回内容 curl_close($ch);//释放句柄 echo $html ?>
如果用这种方法发get请求,参数附加到url后面即可
如curl_setopt($ch, CURLOPT_URL, "http://localhost/tqj/date/p822.php?name=yyyyy");
实例 2 利用curl发送post请求
php $uri = "http://localhost/tqj/date/p822.php"; // post参数数组 $data = array ( 'name' => 'tianquanjun', 'password' => 'tianquanjun', ); //初始化 $ch = curl_init (); //各种项设置,网上参考而来,可以查看php手册,自己设置 curl_setopt ( $ch, CURLOPT_URL, $uri ); curl_setopt ( $ch, CURLOPT_POST, 1 );//post方式 curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); //执行 $return = curl_exec ( $ch ); //释放 curl_close ( $ch ); print_r($return); ?>
实例三 :curl 过程调试与错误信息处理
php $uri = "http://localhost/tqj/date/p822.php"; // post参数数组 $data = array ( 'name' => 'tianquanjun', 'password' => 'tianquanjun', ); //初始化 $ch = curl_init (); //各种项设置,网上参考而来,可以查看php手册,自己设置 curl_setopt ( $ch, CURLOPT_URL, $uri ); curl_setopt ( $ch, CURLOPT_POST, 1 );//post方式 curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); //执行 $return = curl_exec ( $ch ); //容错机制 if($return === false){ var_dump(curl_error($ch)); } //curl_getinfo()获取各种运行中信息,便于调试 $info = curl_getinfo($ch); echo "执行时间".$info['total_time'].PHP_EOL; //释放 curl_close ( $ch ); print_r($return); ?>
其中利用curl_error()获取错误信息,curl_getinfo()获取运行相关信息。
实例四 上传图片,获取返回信息。
跨域上传图片,同时获取返回信息,这个就能大显身手。和post比较像,注意文件之前加一个@符号
php $uri = "http://localhost/tqj/date/p822.php"; // post参数数组 $data = array ( 'author' => 'tianquanjun', 'upload' => '@C:\Users\tianquanjun.DANGDANG\Pictures\a.jpg', ); //初始化 $ch = curl_init (); //各种项设置,网上参考而来,可以查看php手册,自己设置 curl_setopt ( $ch, CURLOPT_URL, $uri ); curl_setopt ( $ch, CURLOPT_POST, 1 );//post方式 curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); //执行 $return = curl_exec ( $ch ); //容错机制 if($return === false){ var_dump(curl_error($ch)); } //curl_getinfo()获取各种运行中信息,便于调试 $info = curl_getinfo($ch); echo "执行时间".$info['total_time'].PHP_EOL; //释放 curl_close ( $ch ); print_r($return); ?>
实例五 : curl批处理。
curl有一个高级特性,批处理句柄。允许打开多个curl链接。
批处理就是打开多个curl句柄,并把这些句柄指派给一个批处理句柄,然后在while循环里等待处理完毕。curl_multi_exec()算是称得上多线程处理,不过它还是属于异步的范畴。
php header("Content-type: text/html; charset=gbk"); $urls=array('http://www.baidu.com','http://www.qq.com/'); $ch=array(); //批处理句柄 $mh=curl_multi_init(); //打开多个curl句柄,并指派给一个批处理句柄 $ch[0]=curl_init($urls[0]); $ch[1]=curl_init($urls[1]); for($i=0;$i<2;$i++) { curl_setopt($ch[$i],CURLOPT_RETURNTRANSFER,1); curl_multi_add_handle($mh,$ch[$i]); } $running = NULL; do{ usleep(10000); curl_multi_exec($mh,$running);//实现批处理,可以看做curl多线程,实际是异步范畴 }while($running>0); $res=array(); for($j=0;$j<2;$j++) { $res[$j]=curl_multi_getcontent($ch[$j]); } //关闭句柄 for($k=0;$k<2;$k++) { curl_multi_remove_handle($mh,$ch[$k]); } curl_multi_close($mh); print_r($res); ?>
基本算是列举了常用的一些实例。要想灵活运用curl,还是得熟悉curl的各个设置项,这些设置项才是curl的灵魂。
==========================亲测效果===============================================
getwether.php
php $data = "theCityName=邯郸"; $uri = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName"; //初始化 $obj = curl_init(); //设置 curl_setopt($obj, CURLOPT_URL, $uri); curl_setopt($obj, CURLOPT_HEADER, 0); //将头文件的信息作为数据流输出 curl_setopt($obj, CURLOPT_RETURNTRANSFER, 1); //执行后直接返回 curl_setopt($obj, CURLOPT_POST, 1); //post 方式 curl_setopt($obj, CURLOPT_POSTFIELDS, $data); //发送post请求参数 curl_setopt($obj,CURLOPT_USERAGENT, " user-agent:Mozilla/5.0 (Windows NT 6.1; rv:62.0) Gecko/20100101 Firefox/62.0");//浏览器头信息 curl_setopt($obj, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8", "Content-Length:" . strlen($data))); //发送header头信息 $opt = curl_exec($obj); if ($opt === false) { var_dump(curl_error($obj)); } else { var_dump(curl_errno($obj));//int(0) $info = curl_getinfo($obj); echo '执行时间:'.$info['total_time'] . PHP_EOL; // echo $opt; print_r($opt); } curl_close($obj);
var_dump(curl_errno($obj));//int(0) 返回最后一次的错误号
var_dump(curl_error($obj)); //string(0) "" 返回一个保护当前会话最近一次错误的字符串
在cmd命令行中输入:
php -f getwether.php >wether.txt
int(0) 执行时间:0.187<string>河北string> <string>邯郸string> <string>53892string> <string>53892.jpgstring> <string>2018/10/17 22:45:23string> <string>8℃/19℃string> <string>10月17日 多云string> <string>北风小于3级string> <string>1.gifstring> <string>1.gifstring> <string>今日天气实况:气温:12℃;风向/风力:北风 1级;湿度:77%;紫外线强度:弱。空气质量:中。string> <string>紫外线指数:弱,辐射较弱,涂擦SPF12-15、PA+护肤品。 健臻·血糖指数:易波动,血糖易波动,注意监测。 穿衣指数:较舒适,建议穿薄外套或牛仔裤等服装。 洗车指数:较适宜,无雨且风力较小,易保持清洁度。 空气污染指数:中,易感人群应适当减少室外活动。 string> <string>8℃/18℃string> <string>10月18日 多云string> <string>南风小于3级string> <string>1.gifstring> <string>1.gifstring> <string>9℃/19℃string> <string>10月19日 多云string> <string>南风小于3级string> <string>1.gifstring> <string>1.gifstring> <string>邯郸市是河北省最古老的城市,也是我国古代著名的城邑。早在2000多年前的春秋初期,就有邯郸的建制,当时邯郸已是一个人口聚居的城市。战国时作为赵国都城历经158年,秦统一后分别设邯郸县、邯郸郡。当时的邯郸经济昌盛、繁荣发达,与长安、洛阳、开封、成都同称五大都城。邯郸位于河北省南部,地处太行山东麓、淦阳河上,是晋冀鲁豫四省接壤的腹地。邯郸市位于太行山东麓,属暖温带半湿润半干旱大陆季风性气候。特点是四季分明,雨量适中,秋、春两季短,冬、夏两季长。邯郸市的自然环境得天独厚,西倚太行山,东临滏阳河,地势西北高、东南低,中部丘陵起伏,盆地交错;并有沁河、渚河、输元河流经市区(皆属滏阳河支流),丰富的水利资源为农业生产提供了优良的条件。景观:黄梁梦吕仙祠、永年君臣上寿石刻、学步桥、磁州窑、古邺城、兰陵王墓、天子冢、响堂山石窟、磁山古文化遗址等。string>
====================爬去豆瓣电影api==================================
php $uri="https://api.douban.com/v2/movie/in_theaters"; $data="city=邯郸&start=0&count=3"; $obj=curl_init(); curl_setopt($obj,CURLOPT_URL,$uri); curl_setopt($obj,CURLOPT_RETURNTRANSFER,1); curl_setopt($obj,CURLOPT_POSTFIELDS,$data); curl_setopt($obj,CURLOPT_POST,1); curl_setopt($obj,CURLOPT_SSL_VERIFYPEER,0); $opt=curl_exec($obj); if($opt===false){ var_dump(curl_error($obj)); }else{ $info=curl_getinfo($obj); /* echo ''; print_r($info); echo '';*/ $movies=json_decode($opt,true); echo count($movies); echo ''; print_r($movies); echo ''; } curl_close($obj);
结果:
5 Array ( [count] => 3 [start] => 0 [total] => 21 [subjects] => Array ( [0] => Array ( [rating] => Array ( [max] => 10 [average] => 8.1 [stars] => 40 [min] => 0 ) [genres] => Array ( [0] => 剧情 [1] => 动作 [2] => 犯罪 ) [title] => 无双 [casts] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1044899/ [avatars] => Array ( [small] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p35678.jpg [large] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p35678.jpg [medium] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p35678.jpg ) [name] => 周润发 [id] => 1044899 ) [1] => Array ( [alt] => https://movie.douban.com/celebrity/1041390/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p49475.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p49475.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p49475.jpg ) [name] => 郭富城 [id] => 1041390 ) [2] => Array ( [alt] => https://movie.douban.com/celebrity/1016668/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p146.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p146.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p146.jpg ) [name] => 张静初 [id] => 1016668 ) ) [collect_count] => 325710 [original_title] => 無雙 [subtype] => movie [directors] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1014716/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p3555.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p3555.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p3555.jpg ) [name] => 庄文强 [id] => 1014716 ) ) [year] => 2018 [images] => Array ( [small] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2535096871.jpg [large] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2535096871.jpg [medium] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2535096871.jpg ) [alt] => https://movie.douban.com/subject/26425063/ [id] => 26425063 ) [1] => Array ( [rating] => Array ( [max] => 10 [average] => 7.4 [stars] => 40 [min] => 0 ) [genres] => Array ( [0] => 剧情 [1] => 动作 [2] => 武侠 ) [title] => 影 [casts] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1274235/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p805.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p805.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p805.jpg ) [name] => 邓超 [id] => 1274235 ) [1] => Array ( [alt] => https://movie.douban.com/celebrity/1004856/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1415690807.36.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1415690807.36.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1415690807.36.jpg ) [name] => 孙俪 [id] => 1004856 ) [2] => Array ( [alt] => https://movie.douban.com/celebrity/1275564/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1366015827.84.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1366015827.84.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1366015827.84.jpg ) [name] => 郑恺 [id] => 1275564 ) ) [collect_count] => 255137 [original_title] => 影 [subtype] => movie [directors] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1054398/ [avatars] => Array ( [small] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p568.jpg [large] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p568.jpg [medium] => https://img1.doubanio.com/view/celebrity/s_ratio_celebrity/public/p568.jpg ) [name] => 张艺谋 [id] => 1054398 ) ) [year] => 2018 [images] => Array ( [small] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2530513100.jpg [large] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2530513100.jpg [medium] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2530513100.jpg ) [alt] => https://movie.douban.com/subject/4864908/ [id] => 4864908 ) [2] => Array ( [rating] => Array ( [max] => 10 [average] => 5.1 [stars] => 25 [min] => 0 ) [genres] => Array ( [0] => 喜剧 ) [title] => 李茶的姑妈 [casts] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1363857/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1519453932.46.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1519453932.46.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1519453932.46.jpg ) [name] => 黄才伦 [id] => 1363857 ) [1] => Array ( [alt] => https://movie.douban.com/celebrity/1350408/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031126.82.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031126.82.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031126.82.jpg ) [name] => 艾伦 [id] => 1350408 ) [2] => Array ( [alt] => https://movie.douban.com/celebrity/1350407/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031175.04.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031175.04.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1437031175.04.jpg ) [name] => 宋阳 [id] => 1350407 ) ) [collect_count] => 112833 [original_title] => 李茶的姑妈 [subtype] => movie [directors] => Array ( [0] => Array ( [alt] => https://movie.douban.com/celebrity/1313050/ [avatars] => Array ( [small] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1518587170.5.jpg [large] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1518587170.5.jpg [medium] => https://img3.doubanio.com/view/celebrity/s_ratio_celebrity/public/p1518587170.5.jpg ) [name] => 吴昱翰 [id] => 1313050 ) ) [year] => 2018 [images] => Array ( [small] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2533384240.jpg [large] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2533384240.jpg [medium] => https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2533384240.jpg ) [alt] => https://movie.douban.com/subject/27092785/ [id] => 27092785 ) ) [title] => 正在上映的电影-邯郸 )
curl_getinfo函数获得信息:
=============================================curl获得慕课用户信息=================================================
php //C:\phpStudy\PHPTutorial\WWW\curl date_default_timezone_set('PRC'); $data="username=用户名&password=密码&remember=1"; //15510485900 $httpHeader=["Content-Type: application/x-www-form-urlencoded; charset=utf-8","Content-length:".strlen($data)]; $obj=curl_init(); curl_setopt($obj,CURLOPT_URL,"https://www.imooc.com/user/login"); //curl_setopt($obj,CURLOPT_URL,"https://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.19)"); curl_setopt($obj,CURLOPT_RETURNTRANSFER,1); curl_setopt($obj,CURLOPT_COOKIESESSION,true); curl_setopt($obj,CURLOPT_COOKIEFILE,'cookiefile'); curl_setopt($obj,CURLOPT_COOKIEJAR,'cookiefile'); curl_setopt($obj,CURLOPT_COOKIE,session_name().'='.session_id()); curl_setopt($obj,CURLOPT_HEADER,0); curl_setopt($obj,CURLOPT_FOLLOWLOCATION,1); curl_setopt($obj,CURLOPT_SSL_VERIFYPEER,false);//不需要认证 curl_setopt($obj,CURLOPT_POST,1); curl_setopt($obj,CURLOPT_POSTFIELDS,$data); curl_setopt($obj,CURLOPT_HTTPHEADER,$httpHeader); curl_setopt($obj, CURLOPT_TIMEOUT, 300); $return=curl_exec($obj); if($return===false){ var_dump(curl_error($obj)); }else{ var_dump(curl_error($obj)); var_dump(curl_errno($obj)); } //echo $return; //curl_close($obj); //echo 'ceshi '; //die; curl_setopt($obj,CURLOPT_URL,"https://www.imooc.com/u/5510462/courses"); //curl_setopt($obj,CURLOPT_URL,"https://weibo.com/5549088156/profile?topnav=1&wvr=6&is_all=1"); curl_setopt($obj,CURLOPT_POST,0); curl_setopt($obj,CURLOPT_HTTPHEADER,array("Content-type:text/xml;")); $opt=curl_exec($obj); /*if($opt===false){ var_dump(curl_error($obj)); }else{ var_dump(curl_error($obj)); var_dump(curl_errno($obj)); }*/ curl_close($obj); echo $opt;
结果:
string(0) "" int(0) "utf-8">青春阳光爱伟的课程 "X-UA-Compatible" content="IE=edge, chrome=1"> "renderer" content="webkit" /> "qc:admins" content="77103107776157736375" /> "wb:webmaster" content="c4f857219bfae3cb" /> "Access-Control-Allow-Origin" content="*" /> "Cache-Control" content="no-transform " /> "Cache-Control" content="no-siteapp" /> "dns-prefetch" href="//www.imooc.com" /> "dns-prefetch" href="//img.imooc.com" /> "dns-prefetch" href="//img.mukewang.com" /> "apple-touch-icon" sizes="76x76" href="/static/img/common/touch-icon-ipad.png"> "apple-touch-icon" sizes="120x120" href="/static/img/common/touch-icon-iphone-retina.png"> "apple-touch-icon" sizes="152x152" href="/static/img/common/touch-icon-ipad-retina.png"> "keywords" content="慕课网,慕课官网,MOOC,移动开发,IT技能培训,免费编程视频,php开发教程,web前端开发,在线编程学习,html5视频教程,css教程,ios开发培训,安卓开发教程" /> "description" content="慕课网(IMOOC)是学习编程最简单的免费平台。慕课网提供了丰富的移动端开发、php开发、web前端、html5教程以及css3视频教程等课程资源。它富有交互性及趣味性,并且你可以和朋友一起编程。" /> "stylesheet" href="/static/moco/v1.0/dist/css/moco.min.css?t=201810221819" type="text/css" /> "stylesheet" href="/static/lib/swiper/swiper-3.4.2.min.css?t=201810221819"> "stylesheet" href="/static/lib/layer/1.6.0/skin/layer.css" /> "stylesheet" href="//static.mukewang.com/static/css/??base.css,common/common-less.css?t=2.5,u/u_common_new-less.css,u/courses/time-less.css?v=201810221819" type="text/css" />"header">class="newcomer index hide" href="//www.imooc.com/act/newcomer" target="_blank"> class="js-close imv2-close">class="page-container" id="nav" >class="nav-item">
- class="set-btn visible-xs-block">"/user/newlogin" target="_self">登录 / "/user/newsignup" target="_self">注册
- "/course/list" target="_self">免费课程
- "//coding.imooc.com" target="_self">实战课程
- "//class.imooc.com" class="" target="_self">就业班
- "/wenda" target="_self">猿问
- "/article" target="_self">手记
- "//job.imooc.com" class="program-nav" target="_self">猿聘class="icn-new">
"login-area">class="header-unlogin clearfix">
- class="app-load" id="js-app-load"> "//www.imooc.com/mobile/app" target="_blank" style="width:60px;">下载APP
class="app-load-box clearfix js-load-box"> "/static/img/common/appload.png" class="l">- class="shop-cart" id="shop-cart"> "//order.imooc.com/pay/cart" class="shop-cart-icon" target="_blank"> class="icon-shopping-cart js-endcart">购物车class="shopping_icon js-cart-num" data-ordernum="0" data-cartnum="0" style='display: none'>0
class="my-cart" id="js-my-cart">- class="header-signin"> "//www.imooc.com/user/newlogin" id="js-signin-btn">登录 / "//www.imooc.com/user/newsignup" id="js-signup-btn">注册
class='search-warp clearfix' style='min-width: 32px; height: 72px;'>class="pa searchTags" > "//class.imooc.com/sc/20" target="_blank">前端入门 "//class.imooc.com/sc/18" target="_blank">Java基础class="search-area" data-search="top-banner"> class="search-input" data-suggest-trigger="suggest-trigger" type="text" autocomplete="off"> 'hidden' class='btn_search' data-search-btn="search-btn" />class="search-area-result" data-suggest-result="suggest-result">
class='showhide-search' data-show='no'>class='icon-search'>class="bindHintBox js-bindHintBox hide">class="pr"> 为了账号安全,请及时绑定邮箱和手机"/user/setbindsns" class="ml20 color-red" target="_blank">立即绑定class="arrow">"main">class="bg-other user-head-info">class="user-info clearfix">class="user-pic" data-is-fans="" data-is-follows="">class="user-pic-bg"> class='img' src="//img3.mukewang.com/533e4c420001b2e502000200-140-140.jpg" alt=""/>class="user-info-right">class="user-name clearfix"> 青春阳光爱伟
class="about-info"> 男 北京 PHP开发工程师 class="more-user-info">class="imv2-arrow2_d">更多信息
class="user-sign hide">class="user-desc" title="努力学习">努力学习
class="study-info clearfix">class="item follows">class="u-info-learn" title="学习时长167小时26分" style="cursor:pointer;"> 167h 学习时长class="item follows"> 3532 经验class="item follows"> 2 积分class="item js-u-add-follow hide" data-uid='5510462' data-type="1" > class="status-btn add-follow ">class="icon-add">+关注class="item js-u-already-follow hide" data-uid='5510462' data-type="2"> class="status-btn already-follow">class="imv2-check">已关注class="wrap">class="slider">
- "/u/5510462" > class="icon-home">动态圈class="icon-drop_right">
- "/u/5510462/courses" class="active"> class="icon-tick">免费课程class="icon-drop_right">
- "/u/5510462/plans" > class="imv2-path">职业路径class="icon-drop_right">
- "/u/5510462/bbs" > class="icon-yuanwen">猿问class="icon-drop_right">
- "/u/5510462/articles" > class="icon-blog">手记class="icon-drop_right">
class="u-container">class="c-tab clearfix">class="tool-right r">class="tool-all"> "js-columall" class="tool-item"> 全部课程 class="tool-item icon icon-drop_down">"js-columbd" class="all-cont" style="display:none;">
- "0" href="/u/5510462/courses?sort=time&skill_id=0">全部课程
- "1" href="/u/5510462/courses?sort=time&skill_id=1">PHP
- "220" href="/u/5510462/courses?sort=time&skill_id=220">Java
- "468" href="/u/5510462/courses?sort=time&skill_id=468">Linux
- "952" href="/u/5510462/courses?sort=time&skill_id=952">MySQL
- "1118" href="/u/5510462/courses?sort=time&skill_id=1118">Python
- "4917" href="/u/5510462/courses?sort=time&skill_id=4917">Redis
- "5272" href="/u/5510462/courses?sort=time&skill_id=5272">爬虫
- "/u/5510462/courses?sort=time">全部课程
class="js-course-list my-space-course study-tl">class="clearfix tl-item tl-item-first"> class="time"> 2018 10月22日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="132" data-uid="5510462">
class="course-list-img l"> "/learn/132" target="_blank"> "200" height="113" alt="PHP中的数据传输神器cURL" src="//img.mukewang.com/570762be0001898506000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/132" target="_blank">PHP中的数据传输神器cURL class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学70% class="i-mid span-common">用时 5小时 7分 class="i-right span-common">学习至2-4 用cURL登陆慕课网并下载个人空间页面class="catog-points"> class="i-left span-common">"/u/5510462/notepad/132">笔记 0 class="i-mid span-common">"/u/5510462/course/132/codes">代码 0 class="i-right span-common">"/u/5510462/course/132/questions">问答 0class="clearfix tl-item "> class="time"> 2018 10月14日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="68" data-uid="5510462">
class="course-list-img l"> "/learn/68" target="_blank"> "200" height="113" alt="JSON应用场景与实战" src="//img.mukewang.com/578386af00010eea06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/68" target="_blank">JSON应用场景与实战 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 1分 class="i-right span-common">学习至1-4 练习class="catog-points"> class="i-left span-common">"/u/5510462/notepad/68">笔记 0 class="i-mid span-common">"/u/5510462/course/68/codes">代码 0 class="i-right span-common">"/u/5510462/course/68/questions">问答 0class="clearfix tl-item "> class="time"> 2018 10月10日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="845" data-uid="5510462">
class="course-list-img l"> "/learn/845" target="_blank"> "200" height="113" alt="SVN从入门到放弃" src="//img.mukewang.com/5934bac20001a5c906000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/845" target="_blank">SVN从入门到放弃 class="i-new">更新至6-1
class="study-points"> class="i-left span-common">已学19% class="i-mid span-common">用时53分 class="i-right span-common">学习至6-1 常见坑与总结class="catog-points"> class="i-left span-common">"/u/5510462/notepad/845">笔记 0 class="i-mid span-common">"/u/5510462/course/845/codes">代码 0 class="i-right span-common">"/u/5510462/course/845/questions">问答 0- class="course-one" data-courseid="109" data-uid="5510462">
class="course-list-img l"> "/learn/109" target="_blank"> "200" height="113" alt="版本管理工具介绍---SVN篇" src="//img.mukewang.com/570360980001a2de06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/109" target="_blank">版本管理工具介绍---SVN篇 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学43% class="i-mid span-common">用时21分 class="i-right span-common">学习至4-3 SVN 常见问题 Ⅲclass="catog-points"> class="i-left span-common">"/u/5510462/notepad/109">笔记 0 class="i-mid span-common">"/u/5510462/course/109/codes">代码 0 class="i-right span-common">"/u/5510462/course/109/questions">问答 0class="clearfix tl-item "> class="time"> 2018 09月09日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="533" data-uid="5510462">
class="course-list-img l"> "/learn/533" target="_blank"> "200" height="113" alt="MySQL5.7版本新特性" src="//img.mukewang.com/572afe280001c13406000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/533" target="_blank">MySQL5.7版本新特性 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 0分 class="i-right span-common">学习至1-3 旧版本支持为表增加计算列演练class="catog-points"> class="i-left span-common">"/u/5510462/notepad/533">笔记 0 class="i-mid span-common">"/u/5510462/course/533/codes">代码 0 class="i-right span-common">"/u/5510462/course/533/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月20日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="177" data-uid="5510462">
class="course-list-img l"> "/learn/177" target="_blank"> "200" height="113" alt="初识Python" src="//img.mukewang.com/540e57300001d6d906000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/177" target="_blank">初识Python class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学6% class="i-mid span-common">用时 1小时44分 class="i-right span-common">学习至4-7 Python之创建tupleclass="catog-points"> class="i-left span-common">"/u/5510462/notepad/177">笔记 0 class="i-mid span-common">"/u/5510462/course/177/codes">代码 1 class="i-right span-common">"/u/5510462/course/177/questions">问答 0- class="course-one" data-courseid="799" data-uid="5510462">
class="course-list-img l"> "/learn/799" target="_blank"> "200" height="113" alt="RBAC打造通用web管理权限" src="//img.mukewang.com/5885a1f5000113a506000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/799" target="_blank">RBAC打造通用web管理权限 class="i-new">更新至5-1
class="study-points"> class="i-left span-common">已学12% class="i-mid span-common">用时 5分 class="i-right span-common">学习至2-1 常见的权限模型class="catog-points"> class="i-left span-common">"/u/5510462/notepad/799">笔记 0 class="i-mid span-common">"/u/5510462/course/799/codes">代码 0 class="i-right span-common">"/u/5510462/course/799/questions">问答 0- class="course-one" data-courseid="898" data-uid="5510462">
class="course-list-img l"> "/learn/898" target="_blank"> "200" height="113" alt="PHP中的会话控制" src="//img.mukewang.com/59c3917900011b8106000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/898" target="_blank">PHP中的会话控制 class="i-new">更新至3-5
class="study-points"> class="i-left span-common">已学95% class="i-mid span-common">用时12小时 9分 class="i-right span-common">学习至3-5 自定义会话管理器class="catog-points"> class="i-left span-common">"/u/5510462/notepad/898">笔记 0 class="i-mid span-common">"/u/5510462/course/898/codes">代码 0 class="i-right span-common">"/u/5510462/course/898/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月16日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="887" data-uid="5510462">
class="course-list-img l"> "/learn/887" target="_blank"> "200" height="113" alt="PHP-面向对象" src="//img.mukewang.com/59acb1650001adce06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/887" target="_blank">PHP-面向对象 class="i-new">更新至2-9
class="study-points"> class="i-left span-common">已学82% class="i-mid span-common">用时 2小时27分 class="i-right span-common">学习至2-9 接口类和抽象类以及设计模式class="catog-points"> class="i-left span-common">"/u/5510462/notepad/887">笔记 0 class="i-mid span-common">"/u/5510462/course/887/codes">代码 0 class="i-right span-common">"/u/5510462/course/887/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月15日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="184" data-uid="5510462">
class="course-list-img l"> "/learn/184" target="_blank"> "200" height="113" alt="PHP面向对象编程" src="//img.mukewang.com/572b067f00019abf06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/184" target="_blank">PHP面向对象编程 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学100% class="i-mid span-common">用时 9小时57分 class="i-right span-common">学习至6-1 课程总结class="catog-points"> class="i-left span-common">"/u/5510462/notepad/184">笔记 0 class="i-mid span-common">"/u/5510462/course/184/codes">代码 0 class="i-right span-common">"/u/5510462/course/184/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月08日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="1017" data-uid="5510462">
class="course-list-img l"> "/learn/1017" target="_blank"> "200" height="113" alt="Python最火爬虫框架Scrapy入门与实践" src="//img.mukewang.com/5b5188020001677306000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/1017" target="_blank">Python最火爬虫框架Scrapy入门与实践 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 0分 class="i-right span-common">学习至2-8 保存数据class="catog-points"> class="i-left span-common">"/u/5510462/notepad/1017">笔记 0 class="i-mid span-common">"/u/5510462/course/1017/codes">代码 0 class="i-right span-common">"/u/5510462/course/1017/questions">问答 0- class="course-one" data-courseid="458" data-uid="5510462">
class="course-list-img l"> "/learn/458" target="_blank"> "200" height="113" alt="django初体验" src="//img.mukewang.com/5705d21e0001e4f106000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/458" target="_blank">django初体验 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 0分 class="i-right span-common">学习至3-1 django初体检class="catog-points"> class="i-left span-common">"/u/5510462/notepad/458">笔记 0 class="i-mid span-common">"/u/5510462/course/458/codes">代码 0 class="i-right span-common">"/u/5510462/course/458/questions">问答 0- class="course-one" data-courseid="317" data-uid="5510462">
class="course-list-img l"> "/learn/317" target="_blank"> "200" height="113" alt="python进阶" src="//img.mukewang.com/5705b7350001d59b06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/317" target="_blank">python进阶 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时10分 class="i-right span-common">学习至3-4 python之使用__future__class="catog-points"> class="i-left span-common">"/u/5510462/notepad/317">笔记 0 class="i-mid span-common">"/u/5510462/course/317/codes">代码 0 class="i-right span-common">"/u/5510462/course/317/questions">问答 0- class="course-one" data-courseid="702" data-uid="5510462">
class="course-list-img l"> "/learn/702" target="_blank"> "200" height="113" alt="轻松学会Laravel-高级篇" src="//img.mukewang.com/581bec530001202106000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/702" target="_blank">轻松学会Laravel-高级篇 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 1分 class="i-right span-common">学习至5-1 Laravel中的文件上传class="catog-points"> class="i-left span-common">"/u/5510462/notepad/702">笔记 0 class="i-mid span-common">"/u/5510462/course/702/codes">代码 0 class="i-right span-common">"/u/5510462/course/702/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月07日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="596" data-uid="5510462">
class="course-list-img l"> "/learn/596" target="_blank"> "200" height="113" alt=" PHP第三方登录—QQ登录" src="//img.mukewang.com/56a0932200014c4d06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/596" target="_blank"> PHP第三方登录—QQ登录 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学87% class="i-mid span-common">用时 3小时36分 class="i-right span-common">学习至5-2 课程总结class="catog-points"> class="i-left span-common">"/u/5510462/notepad/596">笔记 0 class="i-mid span-common">"/u/5510462/course/596/codes">代码 0 class="i-right span-common">"/u/5510462/course/596/questions">问答 0class="clearfix tl-item "> class="time"> 2018 08月01日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="623" data-uid="5510462">
class="course-list-img l"> "/learn/623" target="_blank"> "200" height="113" alt="PHP第三方登录—微博登录" src="//img.mukewang.com/56e1321f0001550c06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/623" target="_blank">PHP第三方登录—微博登录 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学93% class="i-mid span-common">用时11小时12分 class="i-right span-common">学习至4-1 注意事项与课程总结class="catog-points"> class="i-left span-common">"/u/5510462/notepad/623">笔记 0 class="i-mid span-common">"/u/5510462/course/623/codes">代码 0 class="i-right span-common">"/u/5510462/course/623/questions">问答 0class="clearfix tl-item "> class="time"> 2018 07月30日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="557" data-uid="5510462">
class="course-list-img l"> "/learn/557" target="_blank"> "200" height="113" alt="PHP第三方登录—OAuth2.0协议" src="//img.mukewang.com/5668dc790001aa2b06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/557" target="_blank">PHP第三方登录—OAuth2.0协议 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学100% class="i-mid span-common">用时50分 class="i-right span-common">学习至2-2 步骤一请求OAuth登录页class="catog-points"> class="i-left span-common">"/u/5510462/notepad/557">笔记 1 class="i-mid span-common">"/u/5510462/course/557/codes">代码 0 class="i-right span-common">"/u/5510462/course/557/questions">问答 0class="clearfix tl-item "> class="time"> 2018 07月15日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="416" data-uid="5510462">
class="course-list-img l"> "/learn/416" target="_blank"> "200" height="113" alt="Python文件处理" src="//img.mukewang.com/5705b7940001096106000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/416" target="_blank">Python文件处理 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学0% class="i-mid span-common">用时 0分 class="i-right span-common">学习至4-1 文件练习class="catog-points"> class="i-left span-common">"/u/5510462/notepad/416">笔记 0 class="i-mid span-common">"/u/5510462/course/416/codes">代码 0 class="i-right span-common">"/u/5510462/course/416/questions">问答 0class="clearfix tl-item "> class="time"> 2018 04月20日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="703" data-uid="5510462">
class="course-list-img l"> "/learn/703" target="_blank"> "200" height="113" alt="PHP环境LAMP/LNMP安装与配置" src="//img.mukewang.com/57eb9feb000106ec06000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/703" target="_blank">PHP环境LAMP/LNMP安装与配置 class="i-new">更新完毕
class="study-points"> class="i-left span-common">已学89% class="i-mid span-common">用时 2小时14分 class="i-right span-common">学习至9-1 LAMP/LNMP安装与配置课程总结class="catog-points"> class="i-left span-common">"/u/5510462/notepad/703">笔记 0 class="i-mid span-common">"/u/5510462/course/703/codes">代码 0 class="i-right span-common">"/u/5510462/course/703/questions">问答 0class="clearfix tl-item tl-item-last"> class="time"> 2018 04月18日class="course-list course-list-m">class="clearfix">
- class="course-one" data-courseid="697" data-uid="5510462">
class="course-list-img l"> "/learn/697" target="_blank"> "200" height="113" alt="轻松学会Laravel-基础篇" src="//img.mukewang.com/57a2bd030001018806000338-240-135.jpg" />class="course-list-cont">class="study-hd"> "/learn/697" target="_blank">轻松学会Laravel-基础篇 class="i-new">更新至8-1
class="study-points"> class="i-left span-common">已学4% class="i-mid span-common">用时 3分 class="i-right span-common">学习至1-2 Laravel的版本选择class="catog-points"> class="i-left span-common">"/u/5510462/notepad/697">笔记 0 class="i-mid span-common">"/u/5510462/course/697/codes">代码 0 class="i-right span-common">"/u/5510462/course/697/questions">问答 0class="qa-comment-page">class="page">class="disabled_page">首页class="disabled_page">上一页"javascript:void(0)" class="active text-page-tag">1class="text-page-tag" href="/u/5510462/courses?page=2">2class="text-page-tag" href="/u/5510462/courses?page=3">3"/u/5510462/courses?page=2">下一页"/u/5510462/courses?page=3">尾页"footer" data="u,courses">class="waper">class="footerwaper clearfix">class="followus r"> class="followus-weixin" href="javascript:;" target="_blank" title="微信">class="flw-weixin-box">class="followus-weibo" href="http://weibo.com/u/3306361973" target="_blank" title="新浪微博"> class="followus-qzone" href="http://user.qzone.qq.com/1059809142/" target="_blank" title="QQ空间">class="footer_intro l">class="footer_link">
- "//www.imooc.com/" target="_blank">网站首页
- "/index/companytrain" target="_blank" title="企业合作">企业合作
- "/about/job" target="_blank">人才招聘
- "/about/contact" target="_blank">联系我们
- "/about/recruit" target="_blank">讲师招募
- "/help" target="_blank">帮助中心
- "/user/feedback" target="_blank">意见反馈
- "http://daxue.imooc.com/" target="_blank">慕课大学
- "/about/friendly" target="_blank">友情链接
Copyright © 2018 imooc.com All Rights Reserved | 京ICP备 12003892号-11
"J_GotoTop" class="elevator"> "/user/feedback" class="elevator-msg" target="_blank"> class="icon-feedback"> class="">意见反馈 "/help" class="elevator-faq" target="_blank"> class="icon-ques"> class="">帮助中心 "//www.imooc.com/mobile/app" target="_blank" class="elevator-app" > class="icon-appdownload"> class="">APP下载class="elevator-app-box">"javascript:void(0)" class="elevator-weixin no-goto" id="js-elevator-weixin" > class="icon-wxgzh"> class="">官方微信class="elevator-weixin-box">"javascript:void(0)" class="elevator-top no-goto" style="display:none" id="backTop"> class="icon-up2"> class="">返回顶部"layer_sendmsg" class="font-colorg" style="display:none">"display: none">
==================================curl从ftp下载文件=============================================
php $obj=curl_init(); curl_setopt($obj,CURLOPT_URL,"ftp://dele.gotoftp3.com/wwwroot/404.php"); curl_setopt($obj,CURLOPT_HEADER,0); curl_setopt($obj,CURLOPT_RETURNTRANSFER,1); curl_setopt($obj,CURLOPT_TIMEOUT,300);// curl_setopt($obj,CURLOPT_USERPWD,"dee:r9uj");//账号密码 $outfile=fopen('download.php','wb');//保存到本地文件 curl_setopt($obj,CURLOPT_FILE,$outfile); $opt=curl_exec($obj); fclose($outfile); if (!curl_errno($obj)){ echo 'return:'.$opt; }else{ echo 'curl error:'.curl_error($obj); } curl_close($obj);
===================================curl 往ftp上传文件===============================================
php $obj=curl_init(); $fp=fopen('baidu.php','r');//文件句柄 curl_setopt($obj,CURLOPT_URL,"ftp://de.gotoftp3.com/wwwroot/baidu.txt"); curl_setopt($obj,CURLOPT_HEADER,0); curl_setopt($obj,CURLOPT_RETURNTRANSFER,1); curl_setopt($obj,CURLOPT_TIMEOUT,300); curl_setopt($obj,CURLOPT_USERPWD,"dele:r9xdguj"); //对文件设置 操作,上传的文件,文件的大小 curl_setopt($obj,CURLOPT_UPLOAD,1); curl_setopt($obj,CURLOPT_INFILE,$fp); curl_setopt($obj,CURLOPT_INFILESIZE,filesize('baidu.php')); $opt=curl_exec($obj); fclose($fp); if (!curl_errno($obj)){ echo 'success upload'; }else{ echo 'curl error:'.curl_error($obj); } curl_close($obj);
==============================curl 下载https中的数据==============================================
php $obj=curl_init(); date_default_timezone_set('PRC'); curl_setopt($obj,CURLOPT_URL,"https://moco.imooc.com/captcha/script/captcha.min.js?v=1.0"); curl_setopt($obj,CURLOPT_RETURNTRANSFER,1); curl_setopt($obj,CURLOPT_SSL_VERIFYPEER,0); $opt=curl_exec($obj); echo $opt; curl_close($obj);