虎泰克博客

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 至此模拟登陆抓取学号对应信息的就完成了


Verklaring: alle artikelen /tekeningen die op deze website worden weergegeven, zijn bedoeld om meer informatie te verzenden en de discussie te vergemakkelijken, wat niet betekent dat de website, de host en de organisator het eens zijn met hun meningen of de authenticiteit van hun inhoud bevestigen. De inhoud van de artikelen is alleen voor referentie. Indien de rechten van de oorspronkelijke auteur worden geschonden, neem dan contact op met de beheerder van de website.

Schrijf in om commentaar te geven

Lijst van opmerkingen

    Geen gegevens