Created
August 2, 2012 21:56
-
-
Save JasonSanford/3241041 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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