Heim > Fragen und Antworten > Hauptteil
<?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,为什么还是验证码错误
数据分析师2017-09-30 23:57:40
为什么我的模拟登陆登陆时候验证码总是错误-PHP中文网问答-为什么我的模拟登陆登陆时候验证码总是错误-PHP中文网问答
围观一下哦,学习一下。