我有下面的代碼,其中,我試圖打開一系列的URL和在從每個URL(例如:http://apps.mohltc.ca/ltchomes/detail.php?id=2588&lang=en)數據拉。最感興趣的我會是那些標記爲「地方醫療整合網絡」,「被許可方」和「特許牀」。的getElementsByTagName返回[對象HTMLParagraphElement]
既然這樣,我想只是拉與標籤名「P」的所有元素和處理數據清理以後。我的代碼目前拉入「[對象HTML段落元素]」,而不是我希望的數組。有人可以解釋爲什麼這是嗎?
Sub ImportLicenseeData()
Dim ie As Object
Dim LH As Object
Dim r As Integer
Set ie = CreateObject("InternetExplorer.Application")
For r = 4 To 10
With ie
ie.Visible = False
ie.Navigate Cells(r, "H").Value
Do While (ie.Busy Or ie.ReadyState <> 4): DoEvents: Loop
Set Doc = ie.Document
Set LH = Doc.getElementsByTagName("p")
End With
Worksheets("Sheet1").Range("J" & r).Value = LH
Next r
End Sub
任何幫助表示讚賞。
'設置LH = Doc.getElementsByTagName( 「P」)'檢索'DispHTMLElementCollection'對象但不陣列。您應該創建數組循環收集。 – omegastripes