-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (61 loc) · 2.04 KB
/
main.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
67
68
69
70
71
72
73
74
# Program start
# More info in Read.md
print('Would you like to:')
print('1. Update current websites (at the moment skips previous sites)')
print('2. Access a website')
usage = input()
if usage == '1':
# Import file tools
import os
import os.path
# Gets the directory of the files
dir_path = os.path.dirname(os.path.realpath(__file__))
dir_path = dir_path + '\\Sites'
# Import classes
from indexer import Index
from databaser import Data
# TODO: Import link and file
link = "test.com"
# Looks for all html files
for dirpath, dirnames, filenames in os.walk("."):
for filename in [f for f in filenames if f.endswith(".html")]:
dirpath = dirpath[1:]
slash = 0
for l in range(len(dirpath)):
if dirpath[l] == '\\':
slash +=1
if slash >= 2:
break
dirpath = dirpath[l:]
properPath = dir_path + dirpath + '\\' + filename
print(properPath)
i = Index(properPath)
words = i.indexDocument()
d = Data(words, dirpath, properPath)
d.add()
elif usage == '2':
# Imports all my classes
from retriever import Get
from sender import Send
from browser import Display
# What keywords to search for
keywords = input('What would you like to search: ')
find = Get(keywords)
line = find.search()
# Searches for what line(s) the keywords appear on
s = Send(line)
output = s.getPage()
if len(output) > 0:
# Prints outputted links
for r in range (len(output)):
print(output[r])
# This part gets the website in question to show on screen
num = '1 2 3 4 5 6 7 8 9 10'.split()
site = input('Type link or number to get html (1 = first link, 2 = second, etc): ')
if site in num:
show = Display(output[(int(site))-1])
show.run()
else:
show = Display(site)
show.run()
input('Press enter to escape.')