- 授权协议: BSD
- 开发语言: Python
- 操作系统: 跨平台
- 软件首页: http://pyquery.rtfd.org/
- 软件文档: http://pyquery.readthedocs.io/
软件介绍
PyQuery 让你使用 jQuery 的风格来遍历 XML 文档,它使用了 lxml 来处理 XML 乃至 HTML 文档。
你可以直接从字符串、URL或者文件中加载文档:
>>> 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)然后使用 $ 进行遍历:
>>> 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
Head First Python
Paul Barry / O'Reilly Media / 2010-11-30 / USD 49.99
Are you keen to add Python to your programming skills? Learn quickly and have some fun at the same time with Head First Python. This book takes you beyond typical how-to manuals with engaging images, ......一起来看看 《Head First Python》 这本书的介绍吧!
