Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ install:
- pip3 install bs4
script:
- python3 test_getemails.py
- python3 test_getweblinks.py
Binary file modified modules/__pycache__/getemails.cpython-35.pyc
Binary file not shown.
Binary file modified modules/__pycache__/getweblinks.cpython-35.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion modules/getemails.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#from bs4 import BeautifulSoup
import bs4

"""Get all emails from the website"""
Expand Down
37 changes: 22 additions & 15 deletions modules/getweblinks.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import bs4


"""Get all onion links from the website"""
def getLinks(soup):
websites = []
for link in soup.find_all('a'):
email_link = link.get('href')
if email_link != None:
if 'http' in email_link:
websites.append(email_link)
else:
pass
"""Pretty print output as below"""
print ('')
print ('Websites Found - '+str(len(websites)))
print ('-------------------------------')
for web in websites:
print (web)
return ''
_soup_instance = bs4.BeautifulSoup
if isinstance(type(soup), type(_soup_instance)):
websites = []
for link in soup.find_all('a'):
email_link = link.get('href')
if email_link != None:
if 'http' in email_link:
websites.append(email_link)
else:
pass
"""Pretty print output as below"""
print ('')
print ('Websites Found - '+str(len(websites)))
print ('-------------------------------')
for web in websites:
print (web)
return ''
else:
raise('Method parameter is not of instance bs4.BeautifulSoup')
4 changes: 1 addition & 3 deletions tests/test_getemails.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ class getMailsTestCase(unittest.TestCase):
def setUp(self):
self.held, sys.stdout = sys.stdout, StringIO()

def test_return_emails_list(self):
def test_print_emails(self):
data = "\nMails Found - 1\n-------------------------------\nadvertise@provaz.eu\n"
getemails.getMails(soup)
self.assertEqual(sys.stdout.getvalue(),data)

def tearDown(self):
sys.stdout.flush()

if __name__ == '__main__':
unittest.main()
24 changes: 24 additions & 0 deletions tests/test_getweblinks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
import os
import unittest
from io import StringIO
sys.path.append(os.path.abspath('../modules'))
import getweblinks
import pagereader

soup = pagereader.readPage('http://www.whatsmyip.net/')

class getLinksTestCase(unittest.TestCase):

def setUp(self):
self.held, sys.stdout = sys.stdout, StringIO()

def test_print_links(self):
data = "\nWebsites Found - 7\n-------------------------------\nhttp://ads.wsrs.net/www/delivery/ck.php?n=MyIP856a6b4\nhttp://ads.wsrs.net/www/delivery/ck.php?n=MyIPbf5d683\nhttp://aff.ironsocket.com/SH7L\nhttp://aff.ironsocket.com/SH7L\nhttp://ads.wsrs.net/www/delivery/ck.php?n=MyIPdb5f512\nhttp://wsrs.net/\nhttp://cmsgear.com/\n"

getweblinks.getLinks(soup)
self.assertEqual(sys.stdout.getvalue(),data)


if __name__ == '__main__':
unittest.main()