-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
72 lines (59 loc) · 2.48 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
from tkinter import *
from Noticia import Noticia
import webbrowser
from crawler import *
from ScrollableFrame import ScrollableFrame
COLOR_BG = "#f2f2f2"
COLOR_BLACK = "#000000"
class Crawler:
def __init__(self):
self._root = Tk()
self._root.geometry("500x700")
self._root.title("Crawler ")
self._root.configure(background=COLOR_BG)
self._create_top_frame()
self._divider = Frame(self._root, bg=COLOR_BLACK, height=3)
self._divider.pack(side=TOP, fill="x")
self._create_video_frame()
self._video_list = list()
def _create_video_frame(self):
self._video_frame = ScrollableFrame(self._root)
self._video_frame.pack(fill=BOTH, anchor='n', expand=True, side=TOP)
def _create_top_frame(self):
self._top_frame = Frame(self._root, background=COLOR_BG)
self._top_frame.pack(side=TOP, anchor="w", fill="x")
self._root.bind('<Return>', self._sarch)
self._url_text = Entry(self._top_frame, relief=FLAT, highlightcolor=COLOR_BLACK, highlightbackground="grey")
self._url_text.pack(side=RIGHT, anchor="e", fill="x", pady=3, padx=3, expand=True)
def _sarch(self, event):
for child in self._video_frame.scrollable_frame.winfo_children():
child.destroy()
_search = self._url_text.get()
if _search != "":
_url = get_search_url(_search)
_results = get_search_tree(_url[0])
_results2 = get_search_tree(_url[1])
res = get_next_g1(_results)
res2 = get_next_fsp(_results2)
while(res != None):
_new = Noticia(self._video_frame.scrollable_frame, "G1:"+res[0], res[1], res[2])
_new.bind("<Button-1>", self._open_link)
_new.pack(padx=5, fill="x", pady=2)
self._root.update()
res = get_next_g1(res[3])
while(res2 != None):
_new = Noticia(self._video_frame.scrollable_frame, "FSP:"+res2[0], res2[1], res2[2])
_new.bind("<Button-1>", self._open_link)
_new.pack(padx=5, fill="x", pady=2)
self._root.update()
res2 = get_next_fsp(res2[3])
def _open_link(self, event):
webbrowser.open_new(event.widget.url)
print(event.widget.url)
def start(self):
self._root.mainloop()
def main():
myApp = Crawler()
myApp.start()
if __name__ == "__main__":
main()