提取电子邮件HTML元素

问题描述 投票:0回答:1

我正在尝试抓取页面,但有一点要坚持。首先是整个HTML页面的HTML部分

<article class="mod mod-Treffer" data-teilnehmerid="122085958708">
			
			<div data-wipe="{&quot;listener&quot;: &quot;click&quot;, &quot;name&quot;: &quot;Trefferliste Eintrag zur Detailseite&quot;, &quot;id&quot;: &quot;122085958708&quot;, &quot;synchron&quot;: 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 &amp; 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&nbsp;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="{&quot;listener&quot;:&quot;click&quot;,&quot;name&quot;:&quot;Trefferliste: Aktionleiste-button-links&quot;}"></span>
		<span class="mod-gsSlider__arrow mod-gsSlider__arrow--arrow" data-direction="right" data-show="false" data-wipe="{&quot;listener&quot;:&quot;click&quot;,&quot;name&quot;:&quot;Trefferliste: Aktionleiste-button-rechts&quot;}"></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="{&quot;listener&quot;:&quot;click&quot;, &quot;name&quot;:&quot;Trefferliste Webseite-Button&quot;, &quot;id&quot;:&quot;122085958708&quot;}" 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="{&quot;listener&quot;:&quot;click&quot;, &quot;name&quot;:&quot;Trefferliste Email-Button&quot;, &quot;id&quot;:&quot;122085958708&quot;}" data-isneededpromise="false">E-Mail</a>
			
		

		
	
			
				
		
			
			<span class="contains-icon-route_finden gs-btn" data-wipe="{&quot;listener&quot;:&quot;click&quot;, &quot;name&quot;:&quot;Trefferliste Navigation-Button&quot;, &quot;id&quot;:&quot;122085958708&quot;}" data-parameters="{&quot;partner&quot;: &quot;googlemaps&quot;, &quot;searchquery&quot;: &quot;A%20%26%20S%20Billing%20Pflege-Service%20GmbH%20Kirchenberg%202-4%2090482%20N%C3%BCrnberg&quot;}" data-target="_blank">Route</span>
		

		
	
			
				
		
			
			<span class="contains-icon-details gs-btn" data-wipe="{&quot;listener&quot;:&quot;click&quot;, &quot;name&quot;:&quot;Trefferliste Actionbutton Mehr Details&quot;, &quot;id&quot;:&quot;122085958708&quot;}" data-parameters="{&quot;partner&quot;: &quot;gs&quot;, &quot;realId&quot;: &quot;2aeca1d2-2bc5-4070-ac4d-e16b10badca5&quot;, &quot;tnId&quot;: &quot;122085958708&quot;}">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对象没有电子邮件信息,因此仅在找到后才需要提取。

html excel vba css-selectors
1个回答
0
投票

非常感谢。我可以用这些线弄清楚]

    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

但是我欢迎任何其他建议来改进和了解更多。

© www.soinside.com 2019 - 2024. All rights reserved.