quick start:
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=your_url)
d = pq(url=your_url,opener=lambda url, **kw: urlopen(url).read())
d = pq(filename=path_to_html_file)
使用上述任意方法导入html后,d就与jquery的$用法类似了
>>> d("#hello")
[<p#hello.hello>]
>>> p = d("#hello")
>>> print(p.html())
Hello world !
>>> p.html("you know <a href='http://python.org/'>Python</a> rocks")
[<p#hello.hello>]
>>> print(p.html())
you know <a href="http://python.org/">Python</a> rocks
>>> print(p.text())
you know Python rocks
>>> d('p:first')
[<p#hello.hello>]