Skip to content

Instantly share code, notes, and snippets.

@JasonSanford
Created August 2, 2012 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JasonSanford/3241041 to your computer and use it in GitHub Desktop.
Save JasonSanford/3241041 to your computer and use it in GitHub Desktop.
import scraperwiki
import lxml.html
html = scraperwiki.scrape("http://www.greatamericanbeerfestival.com/at-the-festival/breweries-at-the-2012-festival")
root = lxml.html.fromstring(html)
i = 1
for tr in root.cssselect("#brewery_table tbody tr"):
tds = tr.cssselect("td")
data = {
'id' : i,
'name' : tds[0].text_content(),
'city' : tds[1].text_content(),
'state' : tds[2].text_content(),
}
scraperwiki.sqlite.save(unique_keys=['id'], data=data)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment