Guest User

Untitled

a guest
Jul 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4. def get_n_shares_outstanding(ticker):
  5. nasdaq_soup = requests.get("https://www.nasdaq.com/symbol/{}/stock-report".format(ticker))
  6. soup = BeautifulSoup(nasdaq_soup.content, "html.parser")
  7.  
  8. for td in soup.find_all("th",text="Shares Outstanding"):
  9. n_shares_outstanding = int(td.find_next_sibling().get_text().replace(',', ''))
  10.  
  11. return n_shares_outstanding
  12.  
  13.  
  14. get_n_shares_outstanding('AAPL')
Add Comment
Please, Sign In to add comment