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\>\&gt;', 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

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -