虎泰克博客

curl模拟登录教学平台成功!


( ̄ε(# ̄)一下午辛辛苦苦终于弄好了模拟登录,虽然不是模拟的教务处的获取到的数据有点少但还是有点小

( ̄ε(# ̄)一下午辛辛苦苦终于弄好了模拟登录,虽然不是模拟的教务处的获取到的数据有点少但还是有点小开心~ $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 至此模拟登陆抓取学号对应信息的就完成了


Statement: all articles / drawings reproduced on this website are for the purpose of transmitting more information and facilitating discussion, which does not mean that the website, the host and the organizer agree with their opinions or confirm the authenticity of their contents. The contents of the articles are for reference only. If the rights of the original author are violated, please contact the website administrator.

Sign in to comment

Comment list

    No data