77from selenium .webdriver .common .keys import Keys
88import time
99
10- driver_path = input ('Enter chrome driver path' )
10+ driver_path = input ('Enter chrome driver path: ' )
1111
1212
1313# Function to scrape stock data from generated URL
@@ -23,7 +23,7 @@ def scraper():
2323 # Start scraping resultant html data
2424 soup = BeautifulSoup (html , 'html.parser' )
2525
26- # Find the crypto price table to scrape
26+ # Find the crypto price table to scrape
2727 results = soup .find ("table" , {"class" : 'table mx-auto' })
2828 rows = results .findChildren ('tr' )
2929
@@ -48,14 +48,15 @@ def scraper():
4848 single_record += format_cell .format (cell [:20 ])
4949 single_record += "\n "
5050 stocks_data += single_record
51-
51+
5252 # Adding the formatted data into tkinter GUI
5353 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 )
5656 query_label .config (state = tk .DISABLED )
5757 driver .close ()
5858
59+
5960# Creating tkinter window
6061window = tk .Tk ()
6162window .title ('Cryptocurrency Price Checker' )
@@ -69,16 +70,17 @@ def scraper():
6970# label text for title
7071ttk .Label (window , text = "Cryptocurrency Price Checker" ,
7172 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 )
7374
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 )
7577submit_btn .grid (row = 5 , column = 3 , pady = 5 , padx = 15 , ipadx = 5 )
7678
7779frame = ttk .Frame (window , style = 'my.TFrame' )
7880frame .place (relx = 0.50 , rely = 0.12 , relwidth = 0.98 , relheight = 0.90 , anchor = "n" )
7981
8082# 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" )
8284query_label .grid (row = 7 , columnspan = 2 )
8385
8486window .mainloop ()
0 commit comments