Skip to content

Instantly share code, notes, and snippets.

@neilkod
Created June 24, 2011 02:29
Show Gist options
  • Save neilkod/1044108 to your computer and use it in GitHub Desktop.
Save neilkod/1044108 to your computer and use it in GitHub Desktop.
working pyquery example
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)
@webkhushboo
Copy link

IndexError: list index out of range. Its not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment