import urllib.request, urllib.parse, urllib.error
import re

def get_quote(symbol):
    base_url = 'http://finance.google.com/finance?q='
content = urllib.request.urlopen(base_url + symbol).read()
m = re.search('id="ref_694653_l".*?>(.*?)<', content)
if m:
    quote = m.group(1)
else:
    quote = 'no quote available for: ' + symbol
return quote
How to create a stock quote fetching app in python