Skip to content Skip to sidebar Skip to footer

Vba To Fetch Html Url From Webpage

I have created Macro which can read all the HTML of provided URL, however I want to fetch all the url from that HTML. Sub GetHTML_Click() Dim ie As InternetExplorer Dim html A

Solution 1:

Try this :

Dim ie As Object
Dim html As Object
Dim j As Integer
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "google.com"
ie.Navigate URL
Do While ie.ReadyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to go to website ..."
Loop
Application.StatusBar = " "
Set html = ie.Document
'Dim htmltext As Collection
Dim htmlElements As Object
Dim htmlElement As Object
Set htmlElements = html.getElementsByTagName("*")
For Each htmlElement In htmlElements
    If htmlElement.getAttribute("href") <> "" Then Debug.Print htmlElement.getAttribute("href")
Next

Post a Comment for "Vba To Fetch Html Url From Webpage"