shahin
Active Member
Hi there! Hope you all are doing well. I have written a macro to pull a tags from different websites listed in the "storage" variable in my script. In case of just scraping the a tags from listed sites, it is doing awesome. However, the thing I wanna know is that whether there is any built-in function, method whatever in vba with which I can make newly scraped "relative" links "absolute". If it were not for several sites i could have used split method in combination with string concatenation to make usable links. But, as the sites are more than one and the parsed urls are different in their look so I can't think of any idea to make those links absolute. Any input on this will be vastly appreciated.
Btw, it is not necessary to think of any pattern to deal with these predefined sites only because there may be numerous sites in the storage. Thanks in advance.
Code:
Sub Creating_absolute_links()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim storage As String, post As Object, arr() As String, items
storage = "https://www.yify-torrent.org/search/1080p/," & _
"https://yts.ag/browse-movies,https://www.houzz.com/professionals," & _
"https://www.wiseowl.co.uk/videos/"
arr() = Split(storage, ",")
For Each items In arr
With http
.Open "GET", items, False
.send
html.body.innerHTML = .responseText
End With
For Each post In html.getElementsByTagName("a")
row = row + 1: Cells(row, 1) = post.href
Next post
Next items
End Sub
Btw, it is not necessary to think of any pattern to deal with these predefined sites only because there may be numerous sites in the storage. Thanks in advance.