I was wondering if someone can help me with being able to grab/scrape/retrieve an email address from a web page.
I want to create an online petition/contact form, whereby the user can enter their "Post Code" and it will automatically retrieve the email address of their MP.
Add it to the template email I have written and send it to them.
So, I was able to discover the search URL through inspecting the header which is this one: http://www.parliament.uk/mps-lords-and-offices/mps/?search_term=m224fh
The "m224fh" here is the Post Code.
This will then redirect you to the page for your local MP, where one can find their contact details including their email address.
The email is located in the following html tags and elements:
<div id="pnlCommonsAddressDetails">
<div class="contact-detail parliamentary">
<p> ... </p>
<p> ... </p>
<p id="ctl00_ctl00_FormContent_SiteSpecificPlaceholder_PageContent_addParliamentaryAddress_rptAddresses_ctl00_pnlEmail" data-generic-id="email-address"> Email: <a id="ctl00_ctl00_FormContent_SiteSpecificPlaceholder_PageContent_addParliamentaryAddress_rptAddresses_ctl00_hypEmailAddress" href="mailto:this.email.address@parliament.uk">this.email.address@parliament.uk</a></p>
So from the example above, I want to be able to grab/scrape
this.email.address@parliament.uk
and then echo it in my php script to enable the user to email their local MP with the template letter/email I have written.
Thank you very much for the help and guidance in advance.