I have been trying to extract an e-mail address from a website using XPath. There is only 1 email address on the entire page. Is there an easy way to reference that one e-mail address using XPath?
something like: //a/contains(@href,'@')
I tried something similar to what I have posted above with no success, I’d appreciate any advice on a reliable way to pull e-mail address using Xpath. Assume there is only 1 e-mail address on the page with no identifying information other than a simple <a href="mailto:example@george.com"> tag.
Thank you
That will return you the node containing the e-mail address (well, an
@sign at least), not the e-mail address itself.If you can be sure the node contains only the e-mail address and no other adjacent text, you can get it with
If you can’t be sure, you’d have to string-handle it out of the text manually. This is going to be pretty painful in XPath 1.0 since, depending on your implementation, you probably don’t have access to any REGEX functionality.