All pastes #54181 Raw Edit

ccd

public text v1 · immutable
#54181 ·published 2006-05-08 03:44 UTC
rendered paste body
#!/usr/bin/python

import sys
import urllib
from BeautifulSoup import BeautifulSoup

class AppURLopener(urllib.FancyURLopener):
    version = "Mozilla Firefox"

urllib._urlopener = AppURLopener()

argcount=1
helpstring="symbol"

if len(sys.argv) != int(argcount)+1:
        print sys.argv[0]," ",helpstring


def getprice(symbol):
        file = urllib.urlopen("http://finance.google.com/finance?q="+symbol+"&btnG=Search")
        s = file.read()
        file.close()
        soup=BeautifulSoup(s)
        return soup.div.span.string


print getprice(sys.argv[1])