php验证码识别接口(识别率很高)

前两天想模拟登陆知乎,现在的知乎带验证码,而且神出鬼没的在中文和英文之间来回切换。本来识别验证码就很困难了。正好在网上找了一个验证码识别接口,拿来记录一下。

 1 <?php
 2 error_reporting( 0 );
 3 header('Content-Type:text/html;charset=utf-8');
 4 $img = '@D:\WWW\captcha\1.png';//注意@,表示文件上传 
 5 
 6 $data = [ 
 7     'type' => 'recognize', 
 8     'softID' => '3', 
 9     'softKey' => '623527b90698a47ec626043dac04a0f1', 
10     'userName' => 'test', 
11     'passWord' => '123456', 
12     'imagePath' => $img, 
13     'codeType' => '1040',//验证码类型,见下面图片
14     'timeout' => '60', 
15     'remark' => '', 
16     'log' => '0', 
17     'upload' => '开始识别'
18 ]; 
19 
20 $ch = curl_init(); 
21 $url='http://ff.zhima365.com/ZMDemo_PHP/Demo.php'; 
22 curl_setopt($ch, CURLOPT_URL, $url); 
23 curl_setopt($ch, CURLOPT_POST, 1); 
24 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
25 $result = curl_exec($ch); 
26 curl_close($ch);

第四行在php5.5下会报一个警告,但是不影响结果,于是我给忽略了。图片的类型有一个参照的表,按照这个表上的码填入即可:

识别的结果展示效果如下:

竖线第二位的结果就是我们要的结果。

posted @ 2016-10-12 14:57  NickBai  阅读(2260)  评论(0编辑  收藏  举报