Monday, December 8th, 2008p>jQuery came first, but then we have seen others such as pQuery.
Now we have pyQuery which brings the same great
taste API to Python. The author Olivier Lauzanne explains:
yquery allows you to make jquery queries on xml documents. The API is as much as possible the similar to jquery. pyquery uses lxml for fast xml and html manipulation.
It can be used for many purposes, one idea that I might try in the future is to use it for templating with pure http templates that you modify using pyquery.
You can use the PyQuery class to load an xml document from a string, a lxml document, from a file or from an url:PYTHON:
- >>> from pyquery import PyQuery
- >>> from lxml import etree
- >>> d = PyQuery("<html></html>")
- >>> d = PyQuery(etree.fromstring("<html></html>"))
- >>> d = PyQuery(url='http://google.com/')
- >>> d = PyQuery(filename=path_to_html_file)
Add to that the fantastic week that the pythonistas have had as they laud over us with Python 3000 having a final release (which will kick in updates to libraries that are needed to make this backwards not so compatible upgrade viable). It gives a kick in the backside to Perl, Ruby, Java, and even us JS folk :)
Posted by Dion Almaer at 7:45 am