2018-12-28 08:49:56 +08:00
|
|
|
from discovery.constants import *
|
2019-01-11 10:09:47 +08:00
|
|
|
from parsers import myparser
|
|
|
|
import requests
|
2018-12-28 08:49:56 +08:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
class search_trello:
|
|
|
|
|
|
|
|
def __init__(self, word, limit):
|
|
|
|
self.word = word.replace(' ', '%20')
|
|
|
|
self.results = ""
|
|
|
|
self.totalresults = ""
|
2019-01-14 07:58:38 +08:00
|
|
|
self.server = 'www.google.com'
|
|
|
|
self.hostname = 'www.google.com'
|
|
|
|
self.quantity = '100'
|
2018-12-28 08:49:56 +08:00
|
|
|
self.limit = limit
|
|
|
|
self.counter = 0
|
|
|
|
|
|
|
|
def do_search(self):
|
|
|
|
try:
|
2019-01-14 07:58:38 +08:00
|
|
|
urly = 'https://' + self.server + '/search?num=100&start=' + str(
|
|
|
|
self.counter) + '&hl=en&q=site%3Atrello.com%20' + self.word
|
2018-12-28 08:49:56 +08:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
headers = {'User-Agent': googleUA}
|
|
|
|
try:
|
|
|
|
r = requests.get(urly, headers=headers)
|
|
|
|
time.sleep(getDelay())
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
self.results = r.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def get_emails(self):
|
2019-01-06 17:50:07 +08:00
|
|
|
rawres = myparser.Parser(self.totalresults, self.word)
|
2018-12-28 08:49:56 +08:00
|
|
|
return rawres.emails()
|
|
|
|
|
|
|
|
def get_urls(self):
|
|
|
|
try:
|
2019-01-14 07:58:38 +08:00
|
|
|
rawres = myparser.Parser(self.totalresults, 'trello.com')
|
2018-12-28 08:49:56 +08:00
|
|
|
trello_urls = rawres.urls()
|
|
|
|
visited = set()
|
|
|
|
for url in trello_urls:
|
2019-01-11 10:09:47 +08:00
|
|
|
# Iterate through Trello URLs gathered and visit them, append text to totalresults.
|
|
|
|
if url not in visited: # Make sure visiting unique URLs.
|
2018-12-28 08:49:56 +08:00
|
|
|
visited.add(url)
|
|
|
|
self.totalresults += requests.get(url=url, headers={'User-Agent': googleUA}).text
|
2019-01-06 17:50:07 +08:00
|
|
|
rawres = myparser.Parser(self.totalresults, self.word)
|
2018-12-28 08:49:56 +08:00
|
|
|
return rawres.hostnames(), trello_urls
|
|
|
|
except Exception as e:
|
2019-01-06 17:50:07 +08:00
|
|
|
print(f'Error occurred: {e}')
|
2018-12-28 08:49:56 +08:00
|
|
|
|
|
|
|
def process(self):
|
|
|
|
while self.counter < self.limit:
|
|
|
|
self.do_search()
|
|
|
|
if search(self.results):
|
|
|
|
time.sleep(getDelay() * 5)
|
|
|
|
else:
|
|
|
|
time.sleep(getDelay())
|
|
|
|
self.counter += 100
|
2019-01-11 15:21:45 +08:00
|
|
|
print(f'\tSearching {self.counter} results.')
|