Eddy 发布于2010-1-16 23:45:35 分类: 程序设计 已浏览loading 网友评论0条 我要评论


Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) 'DocumentComplete Fires when a document has been completely loaded and initialized.
                                                                                'pDisp: Object that specifies the top-level or frame WebBrowser object corresponding to the event.
On Error Resume Next
    Dim objDoc As Object, objImage As Object '定义两个对象
    If pDisp Is WebBrowser1.object Then 'Is Operator: Used to compare two object reference variables.
        'Document[属性]------Retrieves the automation object of the active document, if any. When the active document is an HTML page, this property provides access to the contents of the HTML Document Object Model (DOM). Specifically, it returns an HTMLDocument object reference.
        'all[集合]------Returns a reference to the collection of elements contained by the object.
        'tags[方法]------Retrieves a collection of objects that have the specified HTML tag name.
        For Each objImage In WebBrowser1.Document.All.tags("IMG")
            If InStr(objImage.src, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") > 0 Then        'xxxxxxxxxxx为验证码图片的地址
                'body[对象]------Specifies the beginning and end of the document body.
                'createControlRange[方法]------Creates a controlRange collection of nontext elements.
                Set objDoc = WebBrowser1.Document.Body.CreateControlRange()
                'controlRange Collection------A collection of elements returned by the createControlRange or createRange method
                'add[方法]------Adds an element to the areas, controlRange, or options collection.
                'execCommand[方法]------Executes a command on the current document, current selection, or the given range.
                objDoc.Add objImage
                objDoc.execCommand "Copy"
                Image1.Picture = Clipboard.GetData
            End If
    End If
End Sub


原创文章如转载,请注明:转载自Eddy Blog
原文地址:http://www.rrgod.com/program/325.html     欢迎订阅Eddy Blog

关于 VB  验证码获取  的相关文章

记住我的信息,下次不用再输入 欢迎给Eddy Blog留言