Reputation: 22440
How do I get the email address from this html snippet?
As there are thousand of leads like this in a certain webpage and the text within it is not always found as it is seen here.
The only common thing is the email address located in the first position.
How can I get the email address and ignore the rest?
These are the elements:
<div class="gm_popup"><div class="gm_name">Adel Outfitters</div><div class="gm_address">1221 W 4th St</div><div class="gm_location">Adel, Georgia 31620<div style="display:none" class="w3-address-country">United States</div></div><div class="gm_phone"><span class="gm_phone_label">P:</span> 229-896-7105</div><div class="gm_email">[email protected]<div><div class="gm_website"><a href="https://www.facebook.com/pages/adel-outfitters/132735763434461" target="_blank">https://www.facebook.com/pages/Adel-Outfitters/132735763434461</a></div><br><a target="_blank" class="directions-link" href="http://maps.google.com/?saddr=+&daddr=1221+W 4th St, Adel, Georgia, 31620">Directions<span class="w3-arrow">different stuffs</span></a></div></div></div>
What I tried:
Set post = html.getElementsByClassName("gm_email")(0)
MsgBox post.innerText
The result:
[email protected]
https://www.facebook.com/pages/Adel-Outfitters/132735763434461
Directionsdifferent stuffs
Expected output:
[email protected]
Upvotes: 0
Views: 62
Reputation: 91
The closing </div>
tag is further down which is why you are getting the extra text. Can you chop off anything after a new line? Or check each word in the string and save the one with "@" in it? Bad way of going about it, but it would probably work...
Upvotes: 1