找回密码
 加入
搜索
查看: 8031|回复: 6

[IE类操作] 如何登陆12306后,获取下面地址的验证码!

  [复制链接]
发表于 2013-1-28 10:17:51 | 显示全部楼层 |阅读模式
发表于 2013-1-28 16:03:19 | 显示全部楼层
刚才试了一下 不知道为什么不能从ID获取到图片的对象变量, 不过可以直接再下载一次这个验证码 地址可以在源文件里找到 然后用直接用新验证码可以登陆。
 楼主| 发表于 2013-1-28 17:40:12 | 显示全部楼层
回复 2# zch11230


    给个完整的代码出来试试!
发表于 2013-2-15 21:48:17 | 显示全部楼层
给你一个思路吧,那个我登不上去……
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Include <Clipboard.au3>
#Include <GDIPlus.au3>

$ocrimage = "ocr.bmp"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Pic1 = GUICtrlCreatePic("", 80, 24, 233, 89)
$Button1 = GUICtrlCreateButton("Button1", 104, 176, 209, 49)
$Label1 = GUICtrlCreateLabel("Label1", 104, 272, 292, 129)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                        
                Case $Button1
                        While 1
                                GUICtrlSetData($Label1," 网页正在加载。")
                                $oIE=_IECreate("https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=randp",0,0,0,1)
                                _IELoadWait($oIE,100,10000)
                                If $oIE = 0 Then
                                        GUICtrlSetData($Label1," 网页加载失败。")
                                        $exitloop = 1
                                        _IEQuit($oIE)
                                        ExitLoop
                                EndIf
                                GUICtrlSetData($Label1," 网页成功加载。")
                                Sleep(1000)
                                GUICtrlSetData($Label1," 正在获取验证码。")
                                FileDelete($ocrimage)
                                $oImg = _IEImgGetCollection ($oIE,0);获取索引0的图片对象
                                $oPic = $oIE.Document.body.createControlRange()
                                $oPic.Add($oImg);将图片添加到新创建的集合中(ControlRange)
                                GUICtrlSetData($Label1," 请修改ie安全设置,使允许访问剪贴板以消除提示。")
                                $oPic.execCommand("Copy");将集合复制到剪切板
                                GUICtrlSetData($Label1," 正在获取验证码。")
                                _GDIPlus_Startup()
                                _ClipBoard_Open(0)
                                $iVerifyPics = _ClipBoard_GetDataEx($CF_BITMAP);;从剪贴板获取图片句柄
                                $iVerifyPics = _GDIPlus_BitmapCreateFromHBITMAP($iVerifyPics);;创建图片
                                _GDIPlus_ImageSaveToFile ($iVerifyPics, $ocrimage);;;保存图片到当前脚本目录
                                _ClipBoard_Close()
                                If FileExists($ocrimage) = 1 Then 
                                GUICtrlSetData($Label1," 验证码获取成功。")
                                GUICtrlSetImage($pic1,$ocrimage)
                                ExitLoop
                                Else
                                GUICtrlSetData($Label1," 验证码获取失败。")
                                Sleep(5000)
                                EndIf
                        WEnd

        EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
peter13447 + 20 谢谢分享

查看全部评分

发表于 2013-2-18 13:34:24 | 显示全部楼层
学习中,关注中。
发表于 2013-2-19 11:38:56 | 显示全部楼层
论坛上有关于这方面的资料
发表于 2013-2-22 01:40:12 | 显示全部楼层
不太懂POSTS
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-15 08:11 , Processed in 0.077241 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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