Last active
January 1, 2016 00:09
-
-
Save DiegoVallely/8064607 to your computer and use it in GitHub Desktop.
A simple script to collect a email from site inputted
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
# 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