如题。

解决方案 »

  1.   

    做一个简单的html语法分析,查找"<a "字符串,然后取出"href="后的字符串,就是连接字符串了
      

  2.   

    引用Microsoft HTML ObjectsDim o As New HTMLDocumentPrivate Sub Command1_Click()
        
        o.body.innerHTML = "<a href='asfsaf'>dfafsf</a>" ''网页代码
        
        For i = 0 To o.links.length - 1
            
            MsgBox o.links.Item(i)
            
        Next i
        
    End Sub
      

  3.   

    link的一些属性和方法   
    Contents  Index  Topic Contents
     
    Previous Topic: LI
    Next Topic: LISTING
     LINK--------------------------------------------------------------------------------DescriptionSpecifies a typed relationship between the document and some other resource. For example, this element is used to link external style sheets to the document. ResThis element can be used only within the HEAD tag. PropertiesclassName, disabled, document, href, id, parentElement, readyState, rel, sourceIndex, tagName, title Methodscontains, getAttribute, removeAttribute, setAttribute Collectionsall, children Eventsonerror, onload, onreadystatechange HTML ElementLINK -------------------------------------------------------------------------------- Top of Page 
    &copy; 1997 Microsoft Corporation. All rights reserved. Terms of Use. 
      

  4.   

    其中的" o.body.innerHTML = "<a href='asfsaf'>dfafsf</a>" ''网页代码"
    为何要自己制定网页代码呢?我现在想在一个现有的htm文件中提取。
      

  5.   

    也可以啊,可以用fso读取html文件内容,也可以用Webbrowser控件打开该html文件,返回html对象
      

  6.   

    按上面的例子得到,Invalid use of property
      

  7.   

    webDoc为Webbrowser控件,用Webbrowser控件打开该html文
    Dim Elem As IHTMLElement
    Dim str As String
    For Each Elem In webDoc.All
        str = Elem.tagName
        If str = "href" Then
            
        End If
    Next
      

  8.   

    上面的例子我是试验过了的,在win2000+vb6下通过的或者你用MsgBox o.links.Item(i).href试一下
      

  9.   

    WebBrowser1.Document.Links.length 老有错误你们看看
      

  10.   

    Option ExplicitPrivate Sub Command1_Click()
    Command1.Enabled = False
    WebBrowser1.Navigate2 Text1.Text
    End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)Dim x As Long
    List1.ClearFor x = 0 To WebBrowser1.Document.Links.length - 1
        List1.AddItem WebBrowser1.Document.Links.Item(x)
    Next x
    Command1.Enabled = True
    End SubPrivate Sub WebBrowser1_StatusTextChange(ByVal Text As String)
    Label3 = Text
    End Sub
      

  11.   

    Sub icoll(list)
     Dim i As Integer
     For i = 1 To listlinks.ListCount
     If Left(listlinks.list(i), 7) = "mailto:" Then
     List1.AddItem listlinks.list(i)
      listlinks.RemoveItem i
      End If
      Next
    End Sub Sub RecurseFr(HTMLDoc As HTMLDocument)  If HTMLDoc Is Nothing Then
      ' Not an HTLM document
           Exit Sub
        End If
       Dim BODYElement As IHTMLElement
      Set BODYElement = HTMLDoc.body
       If BODYElement.tagName = "BODY" Then
      Dim ELEMENTCo As IHTMLElementCollection
      Set ELEMENTCo = HTMLDoc.links
      Dim element As HTMLAnchorElement
      For Each element In ELEMENTCo
          listlinks.AddItem (element.href)
          Next
      End If
        
      Dim HTMLFrames As IHTMLFramesCollection2
      Set HTMLFrames = HTMLDoc.frames
      Dim HTMLWnd As HTMLWindow2
      For countFrames = 0 To HTMLFrames.length - 1
      Set HTMLWnd = HTMLFrames(countFrames)
      Call RecurseFr(HTMLWnd.Document)
      Next
      Exit Sub
      MsgBox (Err.Description)
     End Sub
    Private Sub btnGetLinks_Click()
     On Error Resume Next
     Dim theControl As WebBrowser
     Set theControl = WebBrowser1
     Dim HTMLDoc As HTMLDocument
     Set HTMLDoc = WebBrowser1.Document
     listlinks.Clear
     Call RecurseFr(HTMLDoc)
     Call icoll(listlinks)
     End Sub
    Private Sub btnNavigate_Click()
    WebBrowser1.Navigate (editNavURL)
    End SubPrivate Sub Command1_Click()
    Open "C:\1.txt" For Output As #1
    For i = 1 To listlinks.ListCount
        Print #1, listlinks.list(i)
    Next
    Close #1End Sub
    Private Sub Form_Load()
    Dim DocEvents As HTMLDocument
    WebBrowser1.Navigate2 ("http://www.baidu.com")
    End Sub
    Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    Set DocEvents = Nothing
    listlinks.Clear
    editElement = ""
    editID = ""
    End Sub
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    On Error Resume Next
    If pDisp Is WebBrowser1.Object Then
    Set DocEvents = WebBrowser1.Document
    End If
    End Sub看看这个怎么样!我用是好用把那几个commnad button 的名字改成和我这里的一样html webbrowser control 一个2个list boxeditNavURL 是个text box