晚上好,每个人,
我一直在研究在谷歌地图上访问子节点的教程。最终,我想访问谷歌地图中的电话号码信息和地址,但我开始慢慢,因为我是一个新的VBA用户。下面的代码是注释的...问题是我似乎无法找到谷歌访问子(孩子节点)的答案。再次,我开始慢慢来,所以这段代码没有完成我的最终目标,希望它是一个开始。
Private Sub CommandButton3_Click()
' opening IE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Top = 0
objIE.Left = 0
objIE.Width = 800
objIE.Height = 600
'objIE.AddressBar = 0
'objIE.StatueBar = 0
'objIE.Toolbar = 0
objIE.Visible = True
On Error Resume Next
' searching for an arbitrary place
objIE.navigate ("http://maps.google.com/maps?q=" & "AustinCommunityCollege")
If Err.Number <> 0 Then
objIE.Quit
Set objIE = Nothing
MsgBox "Error - begin again"
GoTo thestart:
End If
Do
DoEvents
Loop Until objIE.readyState = 4
' just some code which prints to the text box in my Userform
TextBox2.Text = objIE.Document.body.innerHTML
' variables
Dim doc As HTMLDocument
Set doc = objIE.Document
Dim sDD As String
' this prints to the screen the innertext of the element with a classname of vasquette. Here is where I need to access the childnodes...
sDD = objIE.Document.getElementsByClassName("vasquette")(0).innertext '.ChildNodes.Item(3).innerHTML > this is the code I tried to use but failed.
MsgBox sDD
End Sub
这是CSSPath:
#cards > div:nth-child(4) > div > div > div.cards-entity-right > div:nth-child(2) > span
这是XPath:
//*[@id="cards"]/div[3]/div/div/div[3]/div[2]/span
不确定这是否有帮助。谢谢你的时间。