Skip to content

Instantly share code, notes, and snippets.

@jmg
Created January 6, 2012 16:06
Show Gist options
  • Save jmg/1571205 to your computer and use it in GitHub Desktop.
Save jmg/1571205 to your computer and use it in GitHub Desktop.
lxml scraper example
from lxml import etree
from StringIO import StringIO
import urllib2
url = "http://www.ivao.aero/atcss/list.asp"
data = urllib2.urlopen(url).read()
parser = etree.HTMLParser()
tree = etree.parse(StringIO(data), parser)
table = tree.xpath("/html/body/div/center/table")[0]
for tr in table:
print [td[0].text for td in tr]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment