-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.py
66 lines (55 loc) · 2.49 KB
/
results.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from load_page import Load_page
from color import Color
import os
class Web_results:
def __init__(self,query):
self.parsed_page = Load_page(query)
self.soup = self.parsed_page.get_soup()
def get_site_title(self):
total_results = self.soup.find('div',{'class':'web-results'})
if total_results==None:return False
total_results = self.soup.find('div',{'class':'web-results'}).find_all('div',{'class':'site-result'})
self.site_results = []
for i in total_results:
result = i.find('div',{'class':'site-title'}).text
self.site_results.append(result)
return self.site_results
def get_site_url(self):
total_results = self.soup.find('div',{'class':'web-results'})
if total_results == None:return False
total_results = self.soup.find('div',{'class':'web-results'}).find_all('div',{'class':'site-result'})
self.site_results = []
for i in total_results:
result = i.find('div',{'class':'site-url'}).find('a')
self.site_results.append(result.get('href'))
return self.site_results
def get_site_description(self):
total_results = self.soup.find('div',{'class':'web-results'})
if total_results == None: return False
total_results = self.soup.find('div',{'class':'web-results'}).find_all('div',{'class':'site-result'})
self.site_results = []
for i in total_results:
result = i.find('div',{'class':'site-description'}).text
self.site_results.append(result)
return self.site_results
def get_spell_title(self):
return self.parsed_page.get_spell_title()
def get_spell_description(self):
return self.parsed_page.get_spell_description()
if __name__ == '__main__':
webresults = Web_results(input('Query:: '))
color = Color()
os.system('clear')
if webresults.get_spell_title():
print()
print(color.GREEN + webresults.get_spell_title() + color.DEFAULT)
if webresults.get_spell_description():
print(color.RED + webresults.get_spell_description() + color.DEFAULT)
try: epochs = len(webresults.get_site_title())
except: print("Results Not Found!...");exit()
print()
for epoch in range(epochs):
print(color.BOLD + webresults.get_site_title()[epoch] + color.DEFAULT)
print(color.CYAN + webresults.get_site_url()[epoch] + color.DEFAULT)
print(webresults.get_site_description()[epoch])
print()