curl模拟登录教学平台成功!
随风飘扬 学习 2015年10月14日12:19 2412
( ̄ε(# ̄)一下午辛辛苦苦终于弄好了模拟登录,虽然不是模拟的教务处的获取到的数据有点少但还是有点小
( ̄ε(# ̄)一下午辛辛苦苦终于弄好了模拟登录,虽然不是模拟的教务处的获取到的数据有点少但还是有点小开心~
$curl = curl_init();
$cookie_jar = tempnam('./tmp','cookie');
curl_setopt($curl, CURLOPT_URL,'http://59.69.102.20:81/meol/homepage/common/login.jsp');
curl_setopt($curl, CURLOPT_POST, 1);
$request = 'IPT_LOGINUSERNAME='.$username.'&IPT_LOGINPASSWORD='.$username.'';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_jar);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_NOBODY, false);
curl_exec($curl);
curl_close($curl);
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_URL, 'http://59.69.102.20:81/meol/homepage/common/index.jsp');
curl_setopt($curl2, CURLOPT_HEADER, false);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_COOKIEFILE, $cookie_jar);
$content = curl_exec($curl2);
$preg = "/(.*)<\/span>/i";
preg_match_all($preg, $content, $arr);
$str = $arr[1][8];//匹配到名字所在的位置
$str = substr($str,0,strlen($str)-2); //去除名字后面的逗号
$str=iconv("gb2312","UTF-8",$str);//转换编码为UTF-8
至此模拟登陆抓取学号对应信息的就完成了
声明:凡本网转载的文/图等稿件,均出于传递更多信息及方便探讨之目的,并不意味着本站及主办、承办单位赞同其观点或证实其内容的真实性,文章内容仅供参考,如果侵犯了原作者的权利请与网站管理员联系。
评论列表
-
暂无数据