Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time #library1 dunno why he called this library, for accuracy of the ratio perhaps?
- import urllib2 #library2 of course I need this, but what does it actually do??
- from urllib2 import urlopen #will look up actual effect
- sp500short = ['a', 'aa', 'aapl', 'abbv', 'abc', 'abt', 'ace', 'aci', 'acn', 'act', 'adbe', 'adi', 'adm', 'adp'] #sample stock names
- def yahooKeyStats(stock): #function for yahoo finance info grabber
- try: #will look search for this in pydocs and see other examples for clarity
- sourceCode = urllib2.urlopen('http://finance.yahoo.com/q/ks?s='+stock).read() #analyze/review
- pbr = sourceCode.split('Price/Book (mrq):</td><td class="yfnc_tabledata1">')[1].split('</td>')[0] #You kinda get this, hone this one
- print 'price to book ratio:',pbr #output of Price to Book ratio
- except Exception, e: #except and Exception?? I have no idea! Will research!
- print 'failed in the main loop',str(e) #wtf is e? where did that come from??
- yahooKeyStats('aapl')
- price to book ratio: 6.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement