Within HTML code, I am trying to extract an email address only if it is provided by the user. Here is a sample of the HTML:
<div class="header">
<div class="details">
<span>
<!-- Random description here which MAY contain an email address -->
</span>
</div>
</div>
I have managed to get to <span>
by using HTML Agility Pack as follows:
var getWeb = new HtmlWeb();
var pageHtml = getWeb.Load("website here");
IEnumerable<string> listItemHtml = pageHtml.DocumentNode.SelectNodes(
@"//div[@class='header']
/div[@class='details']
/span").Select(span => span.InnerText);
My next challenge is to search through this text and check if an email has been provided, which I am unable to figure out. Could someone please help me with this?