7
7
from selenium .webdriver .common .keys import Keys
8
8
import time
9
9
10
- driver_path = input ('Enter chrome driver path' )
10
+ driver_path = input ('Enter chrome driver path: ' )
11
11
12
12
13
13
# Function to scrape stock data from generated URL
@@ -23,7 +23,7 @@ def scraper():
23
23
# Start scraping resultant html data
24
24
soup = BeautifulSoup (html , 'html.parser' )
25
25
26
- # Find the crypto price table to scrape
26
+ # Find the crypto price table to scrape
27
27
results = soup .find ("table" , {"class" : 'table mx-auto' })
28
28
rows = results .findChildren ('tr' )
29
29
@@ -48,14 +48,15 @@ def scraper():
48
48
single_record += format_cell .format (cell [:20 ])
49
49
single_record += "\n "
50
50
stocks_data += single_record
51
-
51
+
52
52
# Adding the formatted data into tkinter GUI
53
53
query_label .config (state = tk .NORMAL )
54
- query_label .delete (1.0 ,"end" )
55
- query_label .insert (1.0 ,stocks_data )
54
+ query_label .delete (1.0 , "end" )
55
+ query_label .insert (1.0 , stocks_data )
56
56
query_label .config (state = tk .DISABLED )
57
57
driver .close ()
58
58
59
+
59
60
# Creating tkinter window
60
61
window = tk .Tk ()
61
62
window .title ('Cryptocurrency Price Checker' )
@@ -69,16 +70,17 @@ def scraper():
69
70
# label text for title
70
71
ttk .Label (window , text = "Cryptocurrency Price Checker" ,
71
72
background = 'white' , foreground = "DodgerBlue2" ,
72
- font = ("Helvetica" , 30 , 'bold' )).grid (row = 0 , column = 3 ,padx = 300 )
73
+ font = ("Helvetica" , 30 , 'bold' )).grid (row = 0 , column = 3 , padx = 300 )
73
74
74
- submit_btn = ttk .Button (window , text = "Fetch Live Price!" , style = 'my.TButton' , command = scraper )
75
+ submit_btn = ttk .Button (window , text = "Fetch Live Price!" ,
76
+ style = 'my.TButton' , command = scraper )
75
77
submit_btn .grid (row = 5 , column = 3 , pady = 5 , padx = 15 , ipadx = 5 )
76
78
77
79
frame = ttk .Frame (window , style = 'my.TFrame' )
78
80
frame .place (relx = 0.50 , rely = 0.12 , relwidth = 0.98 , relheight = 0.90 , anchor = "n" )
79
81
80
82
# To display stock data
81
- query_label = tk .Text (frame , height = "52" , width = "500" , bg = "lightskyblue1" )
83
+ query_label = tk .Text (frame , height = "52" , width = "500" , bg = "lightskyblue1" )
82
84
query_label .grid (row = 7 , columnspan = 2 )
83
85
84
86
window .mainloop ()
0 commit comments