stay hungry stay foolish

love Ruby.

Pyquery

python pyquery

pyquery,python程序员一定要了解的库,极其好用! 类似于jquery的语法来查询XML文档。pyquery使用lxml库来实现快速XML和HTML操作。 使用easy_install 或者pip安装往往都是应为 lxml库没有安装造成安装失败,所以请事先安装lxml

download 本人使用python2.7

1
2
3
4
5
6
7
8
from pyquery import PyQuery as pq
from lxml import etree
import urllib
d = pq('<html></html>')
d = pq(etree.fromstring("<html></html>"))
d = pq(url='http://google.com/')
# d = pq(url='http://google.com/', opener=lambda url: urllib.urlopen(url).read())
d = pq(filename=path_to_html_file)