我的代码导航到Internet Explorer的URL,我尝试抓取与“ pears”名称相关的文本,如下所示:
Worksheets("Sheet1").Cells(1, 1).Value = IE.document.getElementsByClassName("pears").innerText
已选择引用Microsoft HTML对象库和Microsoft Internet控件。
URL的相关摘录是:
<span id="pears">text to be grabbed<br>and this text too</span>
我收到438错误。
整个代码是:
Sub GetWebStuff()
Dim IE As New InternetExplorer
IE.navigate Worksheets("Sheet1").Cells(1, 2).Value
While IE.readyState <> 4 Or IE.Busy: DoEvents: Wend
Worksheets("Sheet1").Cells(1, 1).Value = IE.document.getElementById("pears").innerText
IE.Quit
Set IE = Nothing
End Sub
为什么?