【发布时间】:2018-06-12 18:19:20
【问题描述】:
我正在尝试从 url 获取连接、基础设施和邻域信息到 excel 下面是我尝试过的 vba 代码,但我收到错误-运行时错误“91”:对象变量或未设置块变量。
Sub test()
Dim oHtml As HTMLDocument
Dim oElement As Object
Set oHtml = New HTMLDocument
With CreateObject("WINHTTP.WinHTTPRequest.5.1")
.Open "GET", "https://www.99acres.com/dasnac-the-jewel-of-noida-sector-75-noida-npxid-r14046?src=NPSRP&sid=UiB8IFFTIHwgUyB8IzEjICB8IG5vaWRhIzUjIHwgQ1AyNSB8IFkgIzE4I3wgIHwgMjUgfCMzIyAgfCA3ICM1I3wgIHwgMjMgfCM0MyMgIHw="
.Send
oHtml.body.innerHTML = .responseText
End With
ele3 = oHtml.getElementById("locHighlightsSlide")
Range("A1") = ele3.innerText
End Sub
下面是我的html代码
<div class="vsp-SliderBar" id="locHighlightsSlide">
<div class="amnLeftScroll noVis amenitiesScrollArrow dev_leftlocHightlights">
<i class="xid_icons xid_icons_1x xid_leftarrow1x"></i>
</div>
<div class="vsp-container">
<div class="vsp-itemsFilm clearAfter animTransMrg350">
<div class="vsp-item highlightsCard">
<div class="highlightsCardHeading">Connectivity</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_metro"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Wave City Centr...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Wave City Centre</span> </div>
<div class="highlightsCardCol">4 km | 20 min</div>
</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_metro"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Golf Course Sta...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Golf Course Station</span> </div>
<div class="highlightsCardCol">5 km | 25 min</div>
</div>
</div>
<div class="vsp-item highlightsCard" id="viewMore_Connectivity" style="display: none;">
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_metro"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Wave City Centr...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Wave City Centre</span> </div>
<div class="highlightsCardCol">4 km | 20 min</div>
</div>
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_metro"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Golf Course Sta...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Golf Course Station</span> </div>
<div class="highlightsCardCol">5 km | 25 min</div>
</div>
</div>
<div class="vsp-item highlightsCard">
<div class="highlightsCardHeading">Infrastructure</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_education"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Manav Rachna In...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Manav Rachna International School</span> </div>
<div class="highlightsCardCol">2 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_education"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Global Indian I...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Global Indian International School</span> </div>
<div class="highlightsCardCol">2 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_health"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Neo Hospital</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
</div>
<div class="vsp-item highlightsCard" id="viewMore_Infrastructure" style="display: none;">
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_education"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Manav Rachna In...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Manav Rachna International School</span> </div>
<div class="highlightsCardCol">2 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_education"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Global Indian I...</span>
<span class="overflowItem" style="top:auto;z-index: 1">Global Indian International School</span> </div>
<div class="highlightsCardCol">2 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_health"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Neo Hospital</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
</div>
<div class="vsp-item highlightsCard">
<div class="highlightsCardHeading">Neighborhood</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-72</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-76</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-51</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
</div>
<div class="vsp-item highlightsCard" id="viewMore_Neighborhood" style="display: none;">
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-72</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-76</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
<div class="highlightsCardRow jsinteraction rel" style="overflow: visible;">
<div class="highlightsCardCol">
<i class="xid_icons xid_icons_1x xid_loc_village"></i>
</div>
<div class="highlightsCardCol jsinteraction" style="overflow: visible;">
<span class="highlightPoint">Sector-51</span>
</div>
<div class="highlightsCardCol">3 km | 15 min</div>
</div>
</div>
</div>
</div>
<div class="amnRightScroll amenitiesScrollArrow dev_rightLocHighlights">
<i class="xid_icons xid_icons_1x xid_rightarrow1x dev_vsp-Next"></i>
</div>
</div>
请在下面的图片中找到我需要的数据。
【问题讨论】:
-
您需要从这些字段中获得哪些信息:徽标?您甚至没有必要澄清您的输出可能是怎样的问题。
标签: vba web-scraping msxml