php curl 自动登录mm.10086.cn


最近好玩,准备使用php curl 来做一个模拟登录的操作,但是在登录的过程中,因为使用到一个验证码的操作,不知道各位有什么好的方法能够识别出图片中的信息,但我现在只能先使用猜的方法了。
URL : http://mm.10086.cn/logon/logon.html?b...

他的登录处理的接口是: http://mm.10086.cn/portal/web/mobileL...

   
  $cookie_file = "cookies.txt";
  
$data = "loginType=1&msisdn=".$phone."&password=".$password."&randomPassword=%E8%AF%B7%E8%BE%93%E5%85%A5+%E6%82%A8%E7%9A%84%E9%AA%8C%E8%AF%81%E7%A0%81&authpassword=c&goHtml=backurl&jid=".$jid;
//echo $data."\r\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://mm.10086.cn/portal/web/mobileLogin.do");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET4.0C; .NET4.0E; InfoPath.2; .NET CLR 1.1.4322; Alexa Toolbar)");
//curl_setopt($ch, CURLOPT_REFERER, "http://mm.10086.cn/logon/logon.html?backurl=http%3A%2F%2Fmm.10086.cn%2Findex.html&fw=000150");
curl_setopt($ch, CURLOPT_HEADER, 1); //不返回header部分
//curl_setopt($ch, CURLOPT_COOKIE, "JSESSIONID=".$path);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURL_HTTP_VERSION_1_1, 1); //强制使用 http 1.1
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); // Cookie management.
//curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'Content-Length:'.strlen($data),
''
));
$output = curl_exec($ch);
//$info = curl_getinfo($ch);
curl_close($ch);
//var_dump($info);
//exit;
return $output;
return json_decode($output);

登录一直提示我验证码错误,我执行上是次,结果没有一次正确,这让我心烦,我通过手工的方式的,随便点几下也都会一次是这样的验证码,请高手看看是哪个地方出了问题,谢谢!

php curl

自宅警备员 11 years, 6 months ago

后来我不断的测试,发现了问题所在,主要在一次请求的时候,会产生一个新的session_id值,从而系统会被认为了不同的用户访问了,从而验证码不可能是正确的。

我系绿坝娘 answered 11 years, 6 months ago

Your Answer