用Webbrowser控件 如何获得网页中的所有超级链接,并把这些超级链接全放到表格中去

解决方案 »

  1.   

    Private Sub GetLinks()
        Dim pDoc3 As IHTMLDocument3
        Set pDoc3 = Web.Document
        Dim pElemColl As IHTMLElementCollection
        Set pElemColl = pDoc3.getElementsByTagName("A")
        For i = 0 To pElemColl.length - 1
            Dim pELem As IHTMLElement
            Set pELem = pElemColl.Item(i, i)
            '增加到LIST中
            List1.AddItem pELem.getAttribute("HREF")
        Next i
    End Sub
      

  2.   

    a=inet1.openurl
    b=split(a,"href=")
    for i=lbound(b) to ubound(b)
    c=split(b(i)," ")
    url=replace(c(lbound(c)),"""")
    replace(url,"'")
    next
    http://bbs.eice.com.cn/blog/user1/3/index.html
      

  3.   

    Dim A    For Each A In WebBrowser.Document.All        If UCase(A.tagName) = "A" Then
            sql = "insert into spidedata (link,title) values ('" & A.href & "','" & A.innerText & "')"
            conn.Execute sql
            DoEvents
            Text1.Text = Text1.Text + 1
            End If
        Next