Skip to content

Instantly share code, notes, and snippets.


Pratap Vardhan pratapvardhan

View GitHub Profile
pratapvardhan /
Created Jun 5, 2014
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(''+name))
return tree.xpath("//a[@id='sector']")[0].text, tree.xpath("//a[@id='sector']")[0].getnext().text