# *** License Information *** # This code is released under the BSD License. # This information must be retained any any releases or changes made to this code. # If you use or make changes to this code, please email andrew@digicool.com # I'd like to know who is using this and what kind of changes might be considered # for incorporation to a future package I'm currently working on. # # *** Changes *** # 20001218: the use of httplib was removed in favor of urllib at the recomendation of David Mika. # This provides proxy support by setting the environmental variable http_proxy. See urllib # documentation on www.python.org. Thanks. # import urllib, string, re version = "0.2" author = "Andrew Sawyers, Dec. 2000" def getQuote(self,sname): f = urllib.urlopen("http://finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv"%sname) data = f.read() data = re.sub('"', '', data) array = string.split(data, ",") symbol = array[0] last = array[1] date = array[2] time = array[3] change = array[4] qopen = array[5] high = array[6] low = array[7] volume = array[8] return {'symbol':symbol, 'last':last, 'date':date, 'time':time, 'change':change, 'qopen':qopen, 'high':high, 'low':low, 'volume':volume} if __name__=="__main__": print getQuote()