This paper introduces the method of Python to realize the stock market information download. Share to everyone for your reference. Specific as follows:
This program downloads the stock market information from Yahoo Finance.
Import urllibdef GetURL (URL): socket = urllib.urlopen (URL) readsocket = Socket.read () socket.close () return readsocketdef printinfo (listinfo): print "Stock Symbol:", listinfo[0] print "Last Trade Price:", L ISTINFO[1] print "Last trade Date:", listinfo[2] print "Last Trade time:", listinfo[3] print "Change:", LISTINFO[4] print "Open:", listinfo[5] print "Day's High:", listinfo[6] print "Day's low :", listinfo[7 ] print "Volume:", Listinfo[8]stocksymbol = Raw_input ("Enter the stock symbol:") Stockurl = "Http://download.financ E.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv&e=.csv "% Stocksymbolstockinfostr = GetURL (StockURL) Stockinfostr = Stockinfostr.rstrip () Stockinfostr = Stockinfostr.split (",") Printinfo (STOCKINFOSTR)
Hopefully this article will help you with Python programming.