我正在尝试抓取页面,但有一点要坚持。首先是整个HTML页面的HTML部分
<article class="mod mod-Treffer" data-teilnehmerid="122085958708">
<div data-wipe="{"listener": "click", "name": "Trefferliste Eintrag zur Detailseite", "id": "122085958708", "synchron": true}" data-realid="2aeca1d2-2bc5-4070-ac4d-e16b10badca5" data-tnid="122085958708" target="_self">
<div class="mod-hervorhebung">
<p class="mod-hervorhebung--partnerHervorhebung" data-hervorhebungsstufe="3">Silber Partner</p>
</div>
<picture class="trefferlisten_logo">
<source media="(min-width: 768px)" srcset="https://ies.v4all.de/0122/GS/0122/5/8335/49428335_310x190.png">
<img alt="" data-lazy-src="https://ies.v4all.de/0122/GS/0122/5/8335/49428335_310x190.png" src="https://ies.v4all.de/0122/GS/0122/5/8335/49428335_310x190.png">
</picture>
<h2 data-wipe-name="Titel">A & S Billing Pflege-Service GmbH</h2>
<p class="d-inline-block mod-Treffer--besteBranche">Ambulante Pflegedienste</p>
<div class="mod mod-Stars mod-Stars--" title="2.9/5" data-float="2,9">
<span class="mod-Stars__text" style="width: 58.000001907348632812500%;">2.9</span>
</div>
<span>2.9</span>
<span>(8)</span>
<address class="mod mod-AdresseKompakt">
<p data-wipe-name="Adresse">
Kirchenberg 2‑4,
<span class="nobr">
90482
Nürnberg
</span>
(Mögeldorf)
</p>
<p class="mod-AdresseKompakt__phoneNumber" data-hochgestellt-position="end" data-wipe-name="Kontaktdaten">(0911) 60 00 99 77</p>
</address>
</div>
<div class="aktionsleiste_kompakt">
<div class="mod-gsSlider mod-gsSlider--noneOnWhite">
<span class="mod-gsSlider__arrow mod-gsSlider__arrow--arrow" data-direction="left" data-show="false" data-wipe="{"listener":"click","name":"Trefferliste: Aktionleiste-button-links"}"></span>
<span class="mod-gsSlider__arrow mod-gsSlider__arrow--arrow" data-direction="right" data-show="false" data-wipe="{"listener":"click","name":"Trefferliste: Aktionleiste-button-rechts"}"></span>
<div class="mod-gsSlider__slider" data-initialized="true">
<a class="contains-icon-homepage gs-btn" target="_blank" rel=" noopener" href="http://www.as-billing.de" data-wipe="{"listener":"click", "name":"Trefferliste Webseite-Button", "id":"122085958708"}" data-isneededpromise="false">Webseite</a>
<a class="contains-icon-email gs-btn" href="mailto:[email protected]?subject=Anfrage%20%C3%BCber%20Gelbe%20Seiten" data-wipe="{"listener":"click", "name":"Trefferliste Email-Button", "id":"122085958708"}" data-isneededpromise="false">E-Mail</a>
<span class="contains-icon-route_finden gs-btn" data-wipe="{"listener":"click", "name":"Trefferliste Navigation-Button", "id":"122085958708"}" data-parameters="{"partner": "googlemaps", "searchquery": "A%20%26%20S%20Billing%20Pflege-Service%20GmbH%20Kirchenberg%202-4%2090482%20N%C3%BCrnberg"}" data-target="_blank">Route</span>
<span class="contains-icon-details gs-btn" data-wipe="{"listener":"click", "name":"Trefferliste Actionbutton Mehr Details", "id":"122085958708"}" data-parameters="{"partner": "gs", "realId": "2aeca1d2-2bc5-4070-ac4d-e16b10badca5", "tnId": "122085958708"}">Mehr Details</span>
</div>
</div>
</div>
</article>
我首先使用这些行
Dim post As Object
Set post = html.querySelectorAll(".mod-Treffer")
For i = 0 To post.Length - 1
Debug.Print post.Item(i).getElementsByTagName("h2")(0).innerText
Debug.Print post.Item(i).getElementsByTagName("Address")(0).getElementsByTagName("p")(1).innerText
'I am stuck with extracting the email
'HERE
Next i
此外,有时post对象没有电子邮件信息,因此仅在找到后才需要提取。
非常感谢。我可以用这些线弄清楚]
If InStr(post.Item(i).getElementsByTagName("a")(1).href, "mailto:") Then
Debug.Print Split(Split(post.Item(i).getElementsByTagName("a")(1).href, "mailto:")(1), "?")(0)
End If
但是我欢迎任何其他建议来改进和了解更多。