找回密码
 加入
搜索
楼主: hackiller

嵌套网页无缓存图片验证码识别

 火... [复制链接]
发表于 2010-1-30 22:23:41 | 显示全部楼层
顺便把那个测试程序的gui的小代码放上
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$size = FileGetSize (@ScriptFullPath)
Global $url = "http://www.10010.com/getImage.jsp"
Global $jpg = @TempDir&'\tem'&$size&'.jpg'
Global $cdb = @TempDir & '\'&$size&'.tmpb'
Global $dll = @TempDir & '\'&$size&'.tmpl'
FileInstall("Captchio.dll", $dll, 0);解压dll
FileInstall("Captchio.cdb", $cdb, 0);解压特征库
RunWait(@COMSPEC & " /c regsvr32 "& $dll & " /s","",@SW_HIDE);注册dll
download()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("验证码识别", 162, 65, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Pic1 = GUICtrlCreatePic($jpg, 55, 10, 40, 20, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent($Pic1, "Button1Click")
GUICtrlCreateLabel("图像:", 10, 12, 40, 17)
$Button1 = GUICtrlCreateButton("下一个", 100, 10, 56, 46, $WS_GROUP)
GUICtrlSetOnEvent($Button1, "Button1Click")
GUICtrlCreateLabel("识别:", 10, 37, 40, 17)
$Input1 = GUICtrlCreateInput("", 55, 35, 41, 21)
shibie()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd
Func Button1Click()
        download()
        GUICtrlSetImage ($Pic1,$jpg)
        shibie()
EndFunc
Func Form1Close()
        GUISetState(@SW_SHOW,$Form1)
        RunWait(@COMSPEC & " /c regsvr32 "& $dll & " /u /s","",@SW_HIDE)        
Exit
EndFunc
Func download()
        InetGet ($url,$jpg, 1, 0)
EndFunc
Func shibie()
        GUICtrlSetData($Input1, _Dispatch($jpg,$cdb))
EndFunc
Func _Dispatch($jpg,$cdb);自动识别验证码的Func
        $obj = ObjCreate("Captchio.cCaptcha")
        $obj.OpenCharDB($cdb)
        $txt = $obj.GetStringFromFile($jpg, 1)
        Return $txt ;返回识别出来的验证码
EndFunc   ;==>_Dispatch
发表于 2010-1-30 22:29:34 | 显示全部楼层
找了一下以前写的代码,比如这个获取页面第1张图片保存下来。。
貌似需要加上这个:
#include <ClipBoard.au3>
#include <IE.au3>
还有什么自己看。。睡觉去了。。。
                $oImg = _IEImgGetCollection ($oIE,0);0=第一张图片
                $oPic = $oIE.Document.body.createControlRange()
                $oPic.Add($oImg)
                $oPic.execCommand("Copy");复制到剪贴板
                $ImageFilePath = ClipGet();获取路径,在临时文件里面
                FileCopy($ImageFilePath,@TempDir&"\pppp.jpg",9);复制到temp文件夹
发表于 2010-1-31 09:11:06 | 显示全部楼层
楼上的那个记不太清了,不知道原理是不是我说的那样,或者使用这个方法【】

当然这两个传送门只是解决你 ...
sanmoking 发表于 2010-1-30 22:18



    呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜
 楼主| 发表于 2010-1-31 09:18:11 | 显示全部楼层
本帖最后由 hackiller 于 2010-1-31 09:38 编辑

最后使用了GDI的方法搞定的 这网页是嵌套的 而且该图片不缓存
相关代码:
                $ogetiamge = _IEFrameGetObjByName($oIE, 'ifm_WebCheckCode')

                $oImgs = _IEImgGetCollection($ogetiamge)
                For $oImg In $oImgs
                        $i += 1
                        If $oImg.src = "http://www.10010.com/getImage.jsp" Then
                                $oPic = $ogetiamge.Document.body.createControlRange()
                                $oPic.Add($oImg)
                                $oPic.execCommand("Copy")
                                $img = ClipGet()
                        EndIf
                Next
                _GDIPlus_Startup()
                _ClipBoard_Open(0)
                $iVerifyPics = _ClipBoard_GetDataEx($CF_BITMAP)
                $iVerifyPics = _GDIPlus_BitmapCreateFromHBITMAP($iVerifyPics)
                _ClipBoard_Close()
                FileDelete(@TempDir & "\getimage.bmp")
                _GDIPlus_ImageSaveToFile($iVerifyPics, @TempDir & "\getimage.bmp")
                $a_Image = myReadImageToArray(@TempDir & "\getimage.bmp", True, 1, 0x777777);71704
                $a_Image = myArrayDelBox($a_Image, 1, 1, 1, 1);去边框
                $s_code_string = myArrarOCR(@ScriptDir & "\CodeFont.txt", $a_Image, 1, $CodeNum, $CodeWidth, "", $func_left, $func_mid, $func_top, $func_bottom)



                $check = _IEGetObjById($oIE, "MobileCheckCode")
                If IsObj($check) Then $check.value = $s_code_string
发表于 2010-1-31 10:46:38 | 显示全部楼层
好高深啊...
发表于 2010-1-31 13:06:14 | 显示全部楼层
有些高深。。看不太懂。。学习了
发表于 2010-1-31 17:40:06 | 显示全部楼层
发表于 2010-1-31 19:28:04 | 显示全部楼层
好帖,顶了...
发表于 2010-2-2 09:49:48 | 显示全部楼层
厉害啊 。 都没看懂~
发表于 2010-2-5 10:07:25 | 显示全部楼层
源码很简单,一个func返回识别结果,你想把结果放到那都行。。关键就是特征库跟dll。。
sanmoking 发表于 2010-1-30 22:03



    .....................2.0.0.81的Captchio啊...我没有成功过 筒子有qq么?联系下,,,
发表于 2010-2-5 10:18:09 | 显示全部楼层
"筒子"很难听啊,什么意思?
发表于 2010-4-8 06:53:18 | 显示全部楼层
bob就是牛叉
发表于 2010-6-10 17:51:10 | 显示全部楼层
来看一看学习一下
发表于 2010-12-14 09:02:32 | 显示全部楼层
sanmoking 老大很强大。。。看了很鼓舞。。。哈哈。。
发表于 2010-12-26 00:34:57 | 显示全部楼层
调用DLL识别的又一个例子,好好学习下。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-17 01:24 , Processed in 0.072331 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表