VB获取网页中的验证码

小歆13年前软件源码04307
VB获取网页中的验证码

函数代码:

Public Function GetImg(WebBrowser, Img, sxz)
'参数
'WebBrowser:等获取验证码网页所在的WebBrowser控件
'Img:显示验证码的Image控件
'sxz:网页中验证码相应属性的属性值
  Dim CtrlRange, x
  For Each x In WebBrowser.Document.All
    If UCase(x.tagName) = "IMG" Then
      'x.src为验证码图片的属性,也可是其他属性 如 x.onload等
      If InStr(x.src, sxz) > 0 Then
        Set CtrlRange = WebBrowser.Document.body.createControlRange()
        CtrlRange.Add (x)
        CtrlRange.execCommand ("Copy")
        Debug.Print "Copy"
        Img.Picture = Clipboard.GetData
      End If
    End If
  Next
End Function


函数调用:

'如获取网页http://www.pceggs.com/login.aspx中的验证码图片代码如下:
'<IMG id=valiCode style="CURSOR: pointer" alt=验证码 src="/VerifyCode_Login.aspx" border=0>
'获取验证码函数调用如下:
Call GetImg(Form1.WebBrowser1, Form1.Image1, "VerifyCode_Login.aspx")

相关文章

555集成电路应用800例.jpg

555集成电路应用800例(新编版)

555集成电路应用800例(新编版)        新编555集成电路应用800例电路4余例而成。本书在简要介绍时基电路5...

VC6.0-a.jpg

VC++6.0(windows7兼容版)下载【中/英】

Visual C++ 6.0 windows7兼容版 VC6.0安装版,完美支持Win7和Win XP系统,亲测可用,在Windows7 64位和 Wind...

VB格式输出函数Format的使用

VB格式输出函数可以使数值、日期或字符串按指定的格式输出。其格式为: Format(<表达式>[, <格式字符串>])...

C语言宏定义的用法

宏定义的用法 注意:宏定义不是函数!! 一般用来简化操作的,但又能避免函数调用那样需要进行切换环境,花费时间。例如: #define max (a,b...

VS 2017 Git failed with a fatal error的解决方案

VS 2017 Git failed with a fatal error的解决方案

问题现象这几天用刚装的VS2017写了个程序,在提交推送到Github过程中提示了“Git failed with a fatal error”错误,输出窗口的提示如下图: 解决方案经过一番折腾...

VB URL编码函数

VB UTF-8 URL编码函数: Public Function UTF8_URLEncoding(szInput)  ...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。