【发布时间】:2021-02-02 03:43:19
【问题描述】:
我正在尝试使用 VBA 从谷歌地图中获取一些数据以提取到 Excel 中。因为我不是 VBA 专家,所以面临一些问题。在侧面的谷歌地图中,如果我们向下滚动,脚本中会出现一些网络结果链接。如果可能,我想提取该链接。在这里,我从头开始尝试,但实际上并没有得到我想要的结果
这里是谷歌地图网址的网络结果的屏幕截图
这里还有一些我尝试但没有成功的代码
Public Sub GmapData()
'On Error Resume Next
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "https://g.page/MiguelLopezSalon?share" ' try with first URLS and second
Do
DoEvents
Loop Until ie.readystate <> 4
Application.Wait (Now + TimeValue("00:00:15"))
Dim MyData As New MSForms.DataObject
MyData.GetFromClipboard
For N = 0 To ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Length - 1
If ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Item(N).innerText = "About this data" Then
ie.document.getElementsByClassName("ugiz4pqJLAG__primary-text gm2-body-2").Item(N).ScrollIntoView (False)
End If
Next N
Application.Wait (Now + TimeValue("00:00:05"))
GMD = ie.document.getElementsByClassName("trex").Item(0).innerHTML ' facing error here
ActiveSheet.Cells(1, 1).Value = GMD
End Sub
【问题讨论】:
标签: web-scraping