I have an email that looks like this:
We’ve received a request to change your email address to example@thisexample.com.
To complete the process, please verify your email address by entering the following verification code.
86761G
This code is temporary and will expire in 30 minutes.
If this wasn’t requested by you, your account information will remain unchanged. No further action is required.
Warm regards, Example.com
I need to parse out the verification code: 86761G . Catch being that the code is dynamic, meaning it's ever changing. What IS static though is the layout of the email, so my thought would be to grab it by the new line index [2] (Even though it looks there's spaces in between it's the third <p>
tag in the Div therefor the [2] index via new lines).
Or my other idea was to do it via the HTML somehow (Don't really wanna use HTMLAgilityPack). The HTML is as follows for the Div:
<td colspan="2" style="padding:1.2em 45px 2em 45px;color:#000;font- family:Corbel, 'Trebuchet MS', 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:.875em;line-height:1.1em;">
<p>We’ve received a request to change your email address to example@thisexample.com.</p>
<p>To complete the process, please verify your email address by entering the following verification code.</p>
<p>86761G</p>
<p>This code is temporary and will expire in 30 minutes.</p>
<p>If this wasn’t requested by you, your account information will remain unchanged. No further action is required.</p>
<p>Warm regards,<br>
example.com</p>
</td>
Any idea how to parse this data out? I was thinking Regex if possible, even though I know that Regex isn't meant for HTML because it's not regular text. If I need HTMLAgilityPack I'll use it, if not though I prefer not. Thank you guys!
Oh side note - I'm using Firefox via Selenium, so there's always the option to use it's built in functions to grab it somehow?
Edit: I'm so stupid. Selenium - FindElementbyXPath (facepalm)