Skip to content

Instantly share code, notes, and snippets.

@lxxstc
Created February 25, 2013 06:56
Show Gist options
  • Save lxxstc/5028209 to your computer and use it in GitHub Desktop.
Save lxxstc/5028209 to your computer and use it in GitHub Desktop.
PyQuery 使用测试 pyquery是一个python版的html parser,有比较好的Python Style接口
#!/usr/bin/env python
url = 'http://foo.com/bar'
d = pq(url=url)
a_tags = d('a').filter(lambda i, this: pq(this).text() == 'some pattern here'.decode('utf-8'))
urls = filter(lambda x: re.search('edocfare.travelsky.com', x), map(lambda x: x.attrib['href'], a_tags))
print urls
url = urls[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment