Skip to content

Instantly share code, notes, and snippets.

@DiegoVallely
Last active January 1, 2016 00:09
Show Gist options
  • Save DiegoVallely/8064607 to your computer and use it in GitHub Desktop.
Save DiegoVallely/8064607 to your computer and use it in GitHub Desktop.
A simple script to collect a email from site inputted
# A simple script to collect a email from site inputted
# create by Diego de Sousa Miranda
# email dsousamiranda@gmail.com
import urllib2
import re
class EmailCollector(object):
def __init__(self, url):
self.url = url
def get_html(self):
self.html = urllib2.urlopen(self.url)
self.data = self.html.read()
self.html.close()
return self.data
def get_email(self):
email = []
try:
if re.search(u"@", self.data).group():
email.append(re.search(u"(\w+)@((\w+\.)?(\w+\.\w+))",
self.data).group())
elif re.search(u"(\(at\))|(\[at\])", self.data).group() == '(at)':
line = re.search(u"(\w+)+((\(at\))|(\[at\]))?((\w+\.)?(\w+\.\w+))",
self.data).group().replace('(at)','@')
email.append(line)
elif re.search(u"(\(at\))|(\[at\])", self.data).group() == '[at]':
line = re.search(u"(\w+)+((\(at\))|(\[at\]))?((\w+\.)?(\w+\.\w+))",
self.data).group().replace('[at]','@')
email.append(line)
except AttributeError:
print "Nothing to Match"
return email
if __name__ == '__main__':
email = EmailCollector("http://seu.site.aqui")
email.get_html()
email.get_email()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment