我得到當我打電話一個錯誤:其被定義爲Datascrape()
:獲取錯誤91在運行中的數據刮代碼
Sub Datascrape()
Dim count, i As Long
Dim ie As Object
count = Sheets("properties-2017-06-05").Cells(1, 10).Value
Sheets("properties-2017-06-05").Range("D7:E" & count).ClearContents
For i = 7 To count
Set ie = CreateObject("internetexplorer.Application")
ie.navigate Sheets("properties-2017-06-05").Cells(i, 3).Value
While ie.busy
DoEvents
Wend
'ie.Visible = True
Application.Wait (Now + TimeValue("00:00:03"))
Sheets("properties-2017-06-05").Cells(i, 4) =
'error happens here
ie.document.getelementsbyclassname("col-xs-12 viewAllReviews")(0).innertext
On Error Resume Next
Sheets("properties-2017-06-05").Cells(i, 5) =
ie.document.getelementsbyclassname("APGWBigDialChart widget")(0).getElementsByTagName("text")(1).innertext
On Error Resume Next
ie.Quit
Next
End Sub
後約3或4次迭代循環的,它拋出一個Error 91
和我不懂爲什麼。
對於初學者,您不應該在循環中創建IE *。對於(可能)等待網頁加載而言,Application.Wait最多是一種不可靠的方法。那是你想要做什麼? –
我需要實際瀏覽不同的網址。如果我不創建ie對象,那麼我得到運行時錯誤, –