Skip to content

Instantly share code, notes, and snippets.

View matanbroner's full-sized avatar
🧙

Matan Broner matanbroner

🧙
View GitHub Profile
@pratapvardhan
pratapvardhan / GFinSectorIndustryBasic.py
Created June 5, 2014 09:56
Python Script to extract Sector and Industry for a company stock listed on Google Finance
from urllib import urlopen
from lxml.html import parse
'''
Returns a tuple (Sector, Indistry)
Usage: GFinSectorIndustry('IBM')
'''
def GFinSectorIndustry(name):
tree = parse(urlopen('http://www.google.com/finance?&q='+name))
return tree.xpath("//a[@id='sector']")[0].text, tree.xpath("//a[@id='sector']")[0].getnext().text