shahin
Active Member
Hi there all! Hope you are doing well. I would like to parse links from web which meet a certain condition. I would like to parse links only which contain "about:/wiki" in its first position, as in "about:/wiki/wikipedia". I suppose, if statement can do the magic. If anyone helps me do it, I would be very grateful. Thanks in advance. By the way, I've uploaded an image to make you understand what i meant, specially when you see the difference between the first two links and the rest.
Code:
Sub ConditionalLink()
Const url = "https://en.wikipedia.org/wiki/Main_Page"
Dim Links As Object, Link As Object
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", url, False
.setRequestHeader "Content-Type", "text/xml"
.send
Set html = CreateObject("htmlfile")
html.body.innerHTML = .responseText
End With
Set Links = html.getElementsByTagName("a")
For Each Link In Links
x = x + 1
Cells(x, 1) = Link.href
Next Link
Set Links = Nothing
End Sub
Attachments
Last edited: