-
-
Notifications
You must be signed in to change notification settings - Fork 669
Expand file tree
/
Copy pathgetemails.py
More file actions
26 lines (24 loc) · 850 Bytes
/
getemails.py
File metadata and controls
26 lines (24 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import bs4
"""Get all emails from the website"""
def getMails(soup):
_soup_instance = bs4.BeautifulSoup
if isinstance(type(soup), type(_soup_instance)):
emails = []
for link in soup.find_all('a'):
email_link = link.get('href')
if email_link != None:
if 'mailto' in email_link:
"""Split email address on"""
email_addr = email_link.split(':')
emails.append(email_addr[1])
else:
pass
"""Pretty print output as below"""
print ('')
print ('Mails Found - '+str(len(emails)))
print ('-------------------------------')
for mail in emails:
print (mail)
return ''
else:
raise('Method parameter is not of instance bs4.BeautifulSoup')