How would I go about scraping sectors for tickers on Yahoo/Google Finance using Python? -
i trying sector classifications tickers using python. how go scraping?
this function designed wondering if there better way go it.
def get_sector(ticker): req=urllib2.request('http://google.com/finance?q='+ str(ticker)) response = urllib2.urlopen(req) the_page = response.read() output = re.search('sector\: \<a id=sector href=\"(.*)\" \>(.*)\<\/a\>\>', the_page, flags=re.ignorecase) if output != none: output = output.group(2) output= htmlparser.htmlparser().unescape(output) return output else: return 'not found' i receiving following error when try iterating on list of tickers in russell 3000:
urlerror:
Comments
Post a Comment