Python 3 Yahoo Finance API Tkinter GUI Script to Scrape Live Stock Prices of Companies Full Project For Beginners

Python 3 Yahoo Finance API Tkinter GUI Script to Scrape Live Stock Prices of Companies Full Project For Beginners

 

Welcome folks today in this blog post we will be scraping live stock prices of companies using yahoo finance apiusing tkinter in python. All the full source code of application is given below.

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install yahoo_fin

 

After installing this library make an app.py file and copy paste the following code

See also  Python 3 Automation Script to Delete All Files Inside a Directory Older than X Days Using OS and Time Modules Full Project For Beginners

 

app.py

 

from yahoo_fin import stock_info
from tkinter import *


def stock_price():

    price = stock_info.get_live_price(e1.get())
    Current_stock.set(price)


master = Tk()
Current_stock = StringVar()

Label(master, text="Company Symbol : ").grid(row=0, sticky=W)
Label(master, text="Stock Result:").grid(row=3, sticky=W)

result2 = Label(master, text="", textvariable=Current_stock,
                ).grid(row=3, column=1, sticky=W)

e1 = Entry(master)
e1.grid(row=0, column=1)

b = Button(master, text="Show", command=stock_price)
b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5)

mainloop()

 

 

Now if you execute the python script by typing the following command

 

python app.py

 

 

 

As you can see AMZN stock price is shown in the desktop app

Leave a Reply