ie.navigate to follow links from A1 to A2000
Hi,
I have low programming skills and cannot solve this one myself.
I have found VBA code online to extract email from website, but it only follows website written in the VBA code.
How is it possible to use ie.navigate to follow all links from A1 to A1000 and in column B to paste corresponding email.
Here is the code I found.
P.S. I got it from quite a popular resource so you might have came across it already. I do not claim the code is mine.
Code:
Sub scrapeHyperlinksWebsite()
Dim ie As InternetExplorer
Dim html As HTMLDocument
Dim Link As Object
Dim ElementCol As Object
Dim erow As Long
Application.ScreenUpdating = False
Set ie = New InternetExplorer
ie.Visible = False
ie.navigate "WEBSITE"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = “Loading website…”
DoEvents
Loop
Set html = ie.document
‘Range(“A2”) = html.DocumentElement.innerHTML
Set ElementCol = html.getElementsByTagName(“a”)
‘Set ElementCol = html.getElementsByTagName(“mailto:”)
For Each Link In ElementCol
If InStr(Link, “mailto:”) Then
erow = Worksheets(“Sheet1”).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Value = Link
Cells(erow, 1) = Right(Link, Len(Link) – InStr(Link, “:”))
Cells(erow, 1).Columns.AutoFit
End If
Next
Set ie = Nothing
Application.StatusBar = “”
Application.ScreenUpdating = True
End Sub
Thank you for attention.
If you manage to know the right answer it would be very appreciated if you could paste it here or give me some hints.
Regards,
Alex