vb中用webbrowser编程模拟浏览器自动访问某个网页中的链接
比如访问http://www.95557.com/svote.htm中的链接

解决方案 »

  1.   

    Private Sub Command1_Click()
        WebBrowser1.Navigate "http://www.95557.com/svote.htm"
    End SubPrivate Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
        Dim a
        
        For Each a In WebBrowser1.Document.All
            If a.tagname = "A" Then
                If a.href = "http://tech.sina.com.cn/mobile/capture.shtml" Then
                    a.Click
                End If
            End If
        Next
    End Sub
      

  2.   

    楼上的五星啊....啧啧...五星就不要蹭分了嘛..再蹭也不可能是六星的,呵呵:)
    Option Explicit
    Private m_bDone As BooleanPrivate Sub Command1_Click()
        If m_bDone Then
            Dim doc As IHTMLDocument2
            Set doc = WebBrowser1.Document
            Dim aLink As HTMLLinkElement
            Set aLink = doc.links(0)
            aLink.Click
        End If
    End SubPrivate Sub Form_Load()
        WebBrowser1.Navigate "http://www.95557.com/svote.htm"
    End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        m_bDone = True
    End Sub
      

  3.   

    Dim aLink As HTMLLinkElement
    for each aLink in doc.links
        //一个一个看吧,喜欢那个就用那个.
    next