forked from Vitosh/VBA_personal
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathInternet.vb
56 lines (41 loc) · 1.32 KB
/
Internet.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Option Explicit
Public Sub TestMe()
Dim lngCounter As Long
Dim strURL As String
Dim IE As Object
Dim colCurrent As Object
Dim link
Dim colLinks As Collection
strURL = "vitoshacademy.com"
Set IE = CreateObject("InternetExplorer.Application")
Set colLinks = New Collection
'IE.Visible = True
IE.navigate strURL
Application.Wait (Now() + TimeValue("0:00:2"))
Set colCurrent = IE.Document.getElementsByTagName("a")
For Each link In colCurrent
'link.Click
'Application.Wait (Now() + TimeValue("0:00:2"))
If Not Contains(colLinks, link) Then colLinks.Add (link)
Debug.Print link.href
'Debug.Print link.textContent
'Debug.Print link.OuterHTML
'Debug.Print "-------------------"
Next link
' For Each link In colLinks
' IE.navigate strURL
' If Not Contains(colLinks, link) Then colLinks.Add (link)
' Next link
Stop
IE.Quit
End Sub
Public Function Contains(col As Collection, key As Variant) As Boolean
Dim var As Variant
For Each var In col
If var = key Then
Contains = True
Exit Function
End If
Next var
Contains = False
End Function