我使用下面的VBA并监视变量IE.document。当网址为IE.navigate =" http://www.mixi.jp"时,我可以使用IE.document.all获取所有网络文字。
但在其他网站中,例如" http://www.yahoo.co.jp" ,我无法获得网络文字。那是为什么?
Sub Main()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.yahoo.co.jp"
Do While IE.Busy Or IE.readyState < 4
DoEvents
Loop
End Sub
答案 0 :(得分:1)
因为这个特定的网站IE.document
不算什么:
动态提供的网站似乎就是这种情况,我在下面使用了are some suggestions here。
虽然我不确定你是否能够轻松地获得所有文字&#34;但你仍然可以迭代你有兴趣提取的元素:
Sub Main()
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "http://www.yahoo.co.jp"
Do While ie.Busy Or ie.readyState < 4
DoEvents
Loop
'Create a collection of DIV elements for example
Dim myElements
DIm ele
Set myElements = ie.Document.Body.GetElementsByTagName("DIV")
'Then you can iterate over the DIV elements/etc., modify as needed.
For each ele in myElements
Debug.Print ele.InnerText
Next
End Sub