I've written a scraper to parse movie information from a torrent site. I used IE
and queryselector
.
My code does parse everything. It throws errors instead of quitting the browser when everything is done. If I cancel the error box then I can see the results.
Here is the full code:
Sub Torrent_Data()
Dim IE As New InternetExplorer, html As HTMLDocument
Dim post As Object
With IE
.Visible = False
.navigate "https://yts.am/browse-movies"
Do While .readyState <> READYSTATE_COMPLETE: Loop
Set html = .Document
End With
For Each post In html.querySelectorAll(".browse-movie-bottom")
Row = Row + 1: Cells(Row, 1) = post.queryselector(".browse-movie-title").innerText
Cells(Row, 2) = post.queryselector(".browse-movie-year").innerText
Next post
IE.Quit
End Sub
I have uploaded two images to show the errors.
Both of the errors are appearing at the same time.
I'm using Internet Explorer 11.
If I try like below it brings the results successfully with no issues.
Sub Torrent_Data()
Dim IE As New InternetExplorer, html As HTMLDocument
Dim post As Object
With IE
.Visible = False
.navigate "https://yts.am/browse-movies"
Do While .readyState <> READYSTATE_COMPLETE: Loop
Set html = .Document
End With
For Each post In html.getElementsByClassName("browse-movie-bottom")
Row = Row + 1: Cells(Row, 1) = post.queryselector(".browse-movie-title").innerText
Cells(Row, 2) = post.queryselector(".browse-movie-year").innerText
Next post
IE.Quit
End Sub
References added to the library:
- Microsoft Internet Controls
- Microsoft HTML Object Library
Is there any reference to add to the library to shake off errors?