shahin
Active Member
I've written a macro using InternetExplorer to get all the movie urls from a torrent site. When I execute my macro, it does fetch all the required urls. However, what I expect is to have those 20 urls outside of the for loop within my macro. When I drag the variable "n_url" (containing the newly scraped links) outside of the for loop and print it, i can get only the last url. How can I achieve it, I meant, I will print the "n_url" outside the loop and still get all the urls?
Code:
Sub torrent_info()
Dim IE As New InternetExplorer, html As HTMLDocument, post As Object
With IE
.Visible = False
.navigate "https://yts.am/browse-movies"
Do Until .readyState = READYSTATE_COMPLETE: Loop
Set html = .document
End With
For Each post In html.getElementsByClassName("browse-movie-bottom")
With post.getElementsByTagName("a")
If .Length Then n_url = .Item(0).href
End With
' Debug.Print n_url ''it can fetch all the 20 urls from that page
Next post
Debug.Print n_url ''if printed out, it will only fetch the last url
IE.Quit
End Sub