Created
August 28, 2012 04:26
-
-
Save karschsp/3494973 to your computer and use it in GitHub Desktop.
Parse Iron Hill Media beer list
This file contains hidden or 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
| #! /usr/bin/env python | |
| import urllib2 as l2 | |
| import lxml.html | |
| import smtplib | |
| from lxml.cssselect import CSSSelector | |
| tappath='//h4[@class="monthly"]' | |
| url = 'http://www.ironhillbrewery.com/media/monthly-releases.htm' | |
| resp = l2.urlopen(url) | |
| data = resp.read() | |
| doc = lxml.html.fromstring(data) | |
| resraw = doc.xpath(tappath) | |
| rawbeers = [x.text_content() for x in resraw] | |
| print rawbeers | |
| beers_str = '\n'.join(rawbeers) | |
| simplebeers = beers_str.encode('ascii', 'ignore') | |
| print(simplebeers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment