forked from cybersecurity-team/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetemails.py
More file actions
34 lines (25 loc) · 949 Bytes
/
Copy pathgetemails.py
File metadata and controls
34 lines (25 loc) · 949 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
27
28
29
30
31
32
33
34
"""
Module returns emails found on webpage
"""
from bs4 import BeautifulSoup
from .getweblinks import get_urls_from_page
from .color import color
def get_mails(soup):
"""
Searches for <a href> tags for links then checks if link contains the
substring 'mailto' indicating that it's an email. If it is determined
to be an email then the link is split and the username is appeneded to
the list
Args:
soup: BeautifulSoup isntance that will be used for parsing
Returns:
emails: list of email IDs
"""
if isinstance(type(soup), type(BeautifulSoup)):
emails = get_urls_from_page(soup, email=True)
# Pretty print output as below
success_string = color(f'Mails Found - {str(len(emails))}', 'green')
print(success_string)
print('-------------------------------')
return emails
raise ValueError('Method parameter is not of instance BeautifulSoup')