Created
April 10, 2018 16:25
-
-
Save TheCodedSelf/848bd2cabc2087aae219aac876336b4c to your computer and use it in GitHub Desktop.
Scrape a web page for any email addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, re | |
def find_email(url): | |
hdr = {'User-Agent': 'Mozilla/5.0'} | |
req = urllib2.Request(url, headers=hdr) | |
try: | |
f = urllib2.urlopen(req) | |
s = f.read() | |
emails = re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",s) | |
return emails | |
except: | |
return 'error' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment