from requests import session
from bs4 import BeautifulSoup as BS
import os
def banner():
print("______________________________________________________________________________")
print(" _____ ___ __ ____ _ ")
print(" / ____| | \ \ / / | _ \ | | ")
print("| | __ ___| |\ \_/ /__ _ _ _ __| |_) | ___ | |_ ___ ___ ___ _ __ ___ ")
print("| | |_ |/ _ \ __\ / _ \| | | | '__| _ / _ \| __/ __| / __/ _ \| '_ ` _ \ ")
print("| |__| | __/ |_ | | (_) | |_| | | | |_) | (_) | |_\__ \| (_| (_) | | | | | |")
print(" \_____|\___|\__||_|\___/ \__,_|_| |____/ \___/ \__|___(_)___\___/|_| |_| |_|")
print("______________________________________________________________________________")
print("\n")
profilesFile = os.getcwd() + '/profiles.txt'
banner()
pagesNo = raw_input('[+] Give number of pages: ')
pagesNo = int(pagesNo)
pagesNo += 1
with session() as s:
for pageNo in range(1, pagesNo):
newLinks = []
print '[+] On page: ' + str(pageNo)
source = s.get('http://www.amazon.com/review/top-reviewers/ref=cm_cr_tr_link_2?ie=UTF8&page=' + str(pageNo)).text
soup = BS(source)
table = soup.find('table', {'class':'crDataGrid'})
links = table.findAll('a')
for link in links:
try:
realLink = link['href']
if 'profile' in realLink:
newLinks.append(realLink)
except:
pass
newLinks2 = list(set(newLinks))
with open(profilesFile,'a') as f:
for l in newLinks2:
f.write(l + '\n')
print '[+] Done!'