如何枚举网页中的全部链接?
解决方案 »
- datagrid1中的数据弄到datagrid2中
- 关于进程PID、线程ID、实例Instance、句柄Handle的问题
- 问题!!!!!!!!!!!!!!!!!!!!!!!!!
- VB中能否做到类似user.name这样
- 我现在已经在office的outlook中的工具栏中嵌入进了一个自定义的按钮(通过dll),其中涉及到了office library 10.0,outlook library 9.0,但
- 关于VB select form where between
- 会的请发表意见,不会的进来学学!!--怎么写这个dll????
- 为何ActiveX DLL 在asp中没有创建成功????
- 由于上一题回帖子的人数众多,导致分数不够,所以再开一帖!继续!关于用vb进行文件的读写问题!
- 如何解决找不到数据库的问题
- 怎么打开和关闭端口
- 求助:帮忙解释一个集合类的语句
Dim Doc As IHTMLDocument2
Dim All As IHTMLElementCollection
Dim L As Integer
Dim i As Integer
Dim Varl As Variant Set Doc = WebBrowser1.document
Set All = Doc.links
L = All.length
For i = 0 To L - 1
Set Varl = All.Item(i, varempty)
List1.AddItem ("链接名称:" & Varl.innerText & " 链接地址:" & Varl.href)
Set Varl = Nothing
Next i
Set All = Nothing
Set Doc = Nothing
End Sub
Option ExplicitDim ExWinsPrivate Sub Form_Load()
Dim winShell As Object
Dim WebB As WebBrowser_V1
Dim IEwin As Object
Dim LVItem As ListItem
Set winShell = CreateObject("shell.application")
Set ExWins = winShell.windows
For Each WebB In ExWins
Set LVItem = Me.LVieWin.ListItems.Add(, , WebB.LocationName)
LVItem.SubItems(1) = WebB.LocationURL
Next
Set winShell = Nothing
End SubPrivate Sub IP过滤_Click()
Dim 过滤地址 As String
Dim i As Long
Dim LVItem As ListItem
If Me.LVlinks.SelectedItem Is Nothing Then Exit Sub
过滤地址 = InputBox("输入过滤地址", "输入框", Me.LVlinks.SelectedItem.SubItems(1))
If 过滤地址 = "" Then Exit Sub
For i = 1 To Me.LVlinks.ListItems.Count
If InStr(Me.LVlinks.ListItems(i).SubItems(1), 过滤地址) Then
Set LVItem = Me.LV过滤.ListItems.Add(, , Me.LVlinks.ListItems(i).Text)
LVItem.SubItems(1) = Me.LVlinks.ListItems(i).SubItems(1)
End If
Next
End SubPrivate Sub LVieWin_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim IEwin As WebBrowser_V1
Dim IEdocument As HTMLDocument
Dim Link As HTMLAnchorElement
Dim LVItem As ListItem
On Error Resume Next
'───错误保护结构───'
'Me.LVlinks.ListItems.Clear
Set IEwin = ExWins(Item.Index - 1)
Set IEdocument = IEwin.Document
If Not IEdocument.links Is Nothing Then
If Not Err Then
For Each Link In IEdocument.links
Set LVItem = Me.LVlinks.ListItems.Add(, , Link.innerText)
LVItem.SubItems(1) = Link.href
Next
End If
End If
If Not IEdocument.activeElement.contentWindow Is Nothing Then
If Not Error Then ' 如果掉用对象不成功则不执行
For Each Link In IEdocument.activeElement.contentWindow.Document.activeElement.contentWindow.Document.links
Set LVItem = Me.LVlinks.ListItems.Add(, , Link.innerText)
LVItem.SubItems(1) = Link.href
Next
End If
End If '───错误保护结构───'
On Error GoTo 0
End SubPrivate Sub LVlinks_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Me.LVlinks.SortKey = ColumnHeader.Index - 1
Me.LVlinks.Sorted = True
End SubPrivate Sub LVlinks_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
Me.PopupMenu Me.IPaddres
End If
End SubPrivate Sub LV过滤_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Me.LV过滤.SortKey = ColumnHeader.Index - 1
Me.LV过滤.Sorted = True
End SubPrivate Sub LV过滤_DblClick()
Dim i As Long
For i = 1 To Me.LV过滤.ListItems.Count
If Me.LV过滤.ListItems(i).Checked Then
Debug.Print Me.LV过滤.ListItems(i).Text
Debug.Print Me.LV过滤.ListItems(i).SubItems(1)
End If
Next
End Sub