I have a list of movies in a sheet that spans from A2:A966 and will run through the list of movies in the A2:A966 and pull the data for the ratings into B2:966 and total reviews into C2:C966.
The output does not display in cells B2 and C2 however there are no errors that arise from running the macro. I've tried all sorts of variations and even tried getting a msgbox to display the results but still nothing.
sub imd_data()
Dim IE As New InternetExplorer, html As HTMLDocument, ele As Object
With IE
.Visible = True
.navigate "http://www.google.com/"
Do Until .readyState = READYSTATE_COMPLETE: Loop
Set html = .document
Set sht = Sheets("Sheet2")
End With
html.getElementById("lst-ib").Value = sht.Range("A2") & " IMDB"
html.getElementById("btnK").Click
Application.Wait Now + TimeValue("00:00:05")
html.getElementsByClassName("rc")(0).getElementsByTagName("a")(0).Click
Application.Wait Now + TimeValue("00:00:05")
For Each ele In html.getElementsByClassName("imdbRating")
With ele.getElementsByClassName("ratingValue")
If .Length Then r = r + 1: Cells(r, 1) = .Item(0).innerText
MsgBox .Item(0).innerText
sht.Range("B2") = .Item(0).innerText
End With
With ele.getElementsByClassName("small")
If .Length Then Cells(r, 2) = .Item(0).innerText
sht.Range("C2") = .Item(0).innerText
End With
Next ele
IE.Quit
End Sub