Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4
- import requests
- def stockprice():
- stock = raw_input('Which stock price would you like?: ' )
- res = requests.get('http://finance.yahoo.com/q?s=' + stock)
- soup = bs4.BeautifulSoup(res.text, 'html.parser')
- #elems looks up current stock price, adding ticker
- elems = soup.select('#yfs_l84_'+stock)
- price = elems[0].text.strip()
- return "The current stock price of "+stock+" is "+price
- print stockprice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement