#!/usr/bin/python2.2 import urllib, cgi from Itpl import itpl as i import cgitb; cgitb.enable() f = cgi.FieldStorage() if not f.has_key('s'): print """Content-Type: text/plain . "stock symbol" . . "price per share" . . "day of the last trade" . . "time of the last trade" . . "change in price since opening" . . "a stock" . . "opening price today" . . "highest price today" . . "lowest price today" . . "number of shares traded today" . "52-week Range" . """ import sys; sys.exit() q = f['s'].value doc = urllib.urlopen('http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgvw&e=.csv&s='+q).read() o = doc.strip().split(',') start = i(' .') print start + i('symbol> $o[0] .') print start + i('price> "$o[1]" .') print start + i('lastTradeDay> $o[2] .') print start + i('lastTradeTime> $o[3] .') print start + i('change> "$o[4]" .') print start + i('open> "$o[5]" .') print start + i('high> "$o[6]" .') print start + i('low> "$o[7]" .') print start + i('volume> "$o[8]" .') print start + i('52wkrange> $o[9] .') print i(' .')