forked from florentbr/SeleniumBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListLinksToExcel(Firefox).vbs
More file actions
34 lines (26 loc) · 1.79 KB
/
ListLinksToExcel(Firefox).vbs
File metadata and controls
34 lines (26 loc) · 1.79 KB
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
'
' VBScript example
' Lists all the links in a web page to an Excel sheet
'
Class Script
Dim driver
Sub Class_Initialize
' Launch the browser and open an URL
Set driver = CreateObject("Selenium.FirefoxDriver")
driver.Get "https://en.wikipedia.org/wiki/Main_Page"
' List all links, remove duplicates and sort them
Set links = driver.FindElementsByCss("a").Attribute("href")
links.Distinct
links.Sort
' Launch Excel and create a Workbook
Set excel = CreateObject("Excel.Application")
excel.WorkBooks.Add ' Add a new workbook
excel.Visible = 1 ' Let Excel show itself
' Write the links in Excel and quit
links.ToExcel excel.ActiveSheet, "Links"
End Sub
Sub Class_Terminate
driver.Quit 'Stop the browser
End Sub
End Class
Set s = New Script