Created
June 24, 2011 02:29
-
-
Save neilkod/1044108 to your computer and use it in GitHub Desktop.
working pyquery example
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
from pyquery import PyQuery | |
import urllib2 | |
data = urllib2.urlopen('http://intermountainallergy.com/pollen.html') | |
d = PyQuery(data.read()) | |
pollen_table = d('table.pollentable') | |
pollen_rows = pollen_table('tr')[1:-1] | |
for row in pollen_rows: | |
fields = row.getchildren() | |
pollen_source = fields[0].text_content() | |
pollen_value = fields[1].getchildren()[0].get('width') | |
print pollen_source.strip(), int(pollen_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IndexError: list index out of range. Its not working