<?php
$curl=curl_init();
$uri="http://jiaowu.em.swjtu.edu.cn/service/login.jsp?user_type=student";
$verify_url="http://jiaowu.em.swjtu.edu.cn/servlet/GetRandomNumberToJPEG";
$post_url="http://jiaowu.em.swjtu.edu.cn/servlet/UserLoginSQLAction";
$cookie_file="cookie.txt";
curl_setopt($curl,CURLOPT_URL,$uri);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,20);
//curl_setopt($curl,CURLOPT_COOKIEJAR,$cookie_file);
curl_setopt($curl,CURLOPT_COOKIEFILE,$cookie_file);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$contents=curl_exec($curl);
curl_close($curl);
echo"获取cookie成功";
$curl=curl_init();
curl_setopt($curl,CURLOPT_COOKIEJAR,$cookie_file);
curl_setopt($curl,CURLOPT_COOKIEFILE,$cookie_file);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,20);
curl_setopt( $curl , CURLOPT_URL, $verify_url );
curl_setopt( $curl , CURLOPT_HEADER, 0);
curl_setopt( $curl , CURLOPT_RETURNTRANSFER, 1);
$img = curl_exec( $curl );
$fp=fopen("x.jpg","w");
fwrite($fp,$img);
fclose($fp);
echo "获取图片成功";
sleep(20);
echo file_get_contents("verify.txt");
$array=array(
"url"=>"../servlet/UserLoginCheckInfoAction",
"password"=>"456jj123",
"OperatingSystem"=>"",
"Browser"=>"",
"user_id"=>"2015121613",
"password"=>"19970826",
"ranstring"=>file_get_contents("verify.txt"),
"user_type"=>"student",
"btn1"=>"",
);
$curl=curl_init();
curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");
curl_setopt($curl,CURLOPT_REFERER,"http://jiaowu.em.swjtu.edu.cn/service/login.jsp?user_type=student");
curl_setopt($curl,CURLOPT_COOKIEFILE,$cookie_file);
curl_setopt($curl,CURLOPT_URL,$post_url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,20);
curl_setopt($curl,CURLOPT_POSTFIELDS,$array);
curl_setopt($curl,CURLOPT_POST,1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);
$result =curl_exec( $curl);
curl_close( $curl );
echo "登陆成功";
我已经保存了session,为什么还是验证码错误
為什麼我的模擬登陸登陸時候驗證碼總是錯誤-PHP中文網問答-為什麼我的模擬登陸登陸時候驗證碼總是錯誤-PHP中文網問答
圍觀一下哦,學習一下。
你这个url地址是不是问题
服务端能不能获取到验证码