Created
February 25, 2013 06:56
-
-
Save lxxstc/5028209 to your computer and use it in GitHub Desktop.
PyQuery 使用测试 pyquery是一个python版的html parser,有比较好的Python Style接口
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
#!/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