Excel VBA-参考HTML<;部门>;属性
几天来,我一直在努力编写一些代码,从网页源代码(下面的屏幕截图链接)中输出“数据全名”的值 我知道我可以使用objCollection(I).className访问instance的'class'值,但是我如何访问其他div属性呢 谢谢大家! 网页源代码截图Excel VBA-参考HTML<;部门>;属性,vba,excel,internet-explorer,Vba,Excel,Internet Explorer,几天来,我一直在努力编写一些代码,从网页源代码(下面的屏幕截图链接)中输出“数据全名”的值 我知道我可以使用objCollection(I).className访问instance的'class'值,但是我如何访问其他div属性呢 谢谢大家! 网页源代码截图 Private Sub-Extract_Info() 我想我会坚持多久 模糊的物体 作为对象的模糊对象 作为对象的Dim OBJ集合 '创建InternetExplorer对象 设置ie=CreateObject(“InternetExp
Private Sub-Extract_Info()
我想我会坚持多久
模糊的物体
作为对象的模糊对象
作为对象的Dim OBJ集合
'创建InternetExplorer对象
设置ie=CreateObject(“InternetExplorer.Application”)
可见=假
即“导航”http://mywebpage.com.au/"
“等一下,我正在装货。。。
忙着干吧
Application.Wait DateAdd(“s”,1,Now)
环
“开始提取
设置objCollection=ie.document.getElementsByTagName(“div”)
i=0
而我
试试:
Private Sub Extract_Info()
Dim i As Long
Dim ie As Object
Dim objElement As Object
Dim objCollection As Object
' Create InternetExplorer Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = False
ie.navigate "http://mywebpage.com.au/"
' Wait while IE loading...
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Begin extraction
Set objCollection = ie.document.getElementsByTagName("div")
i = 0
While i < objCollection.Length
If objCollection(i).ClassName = "listing listing-search listing-data" Then
'Not sure how to code here:
e.g. MsgBox (objCollection(i).data-full-name)
End If
i = i + 1
Wend
End Sub
Debug.Print objCollection(i).getAttribute("data-full-name")