#!/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])