From 040f6453c13730489f48e5aba8b2bef5d3f093f0 Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 29 Aug 2011 09:30:54 -0700 Subject: [PATCH] Attempting to placate github's arcane symlinked-readme rules. --- README | 2 +- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 39 +++++++++++++++++++-------------------- 3 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 README.md diff --git a/README b/README index 92cacd2..42061c0 120000 --- a/README +++ b/README @@ -1 +1 @@ -README.rst \ No newline at end of file +README.md \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1cfa8b --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# PyQuery: a jQuery-like library for Python + +PyQuery allows you to make [jQuery](http://jquery.com)-style CSS-selector queries on XML/HTML +documents. The API is intended to match [jQuery's API](http://api.jquery.com) whenever possible, +though it has been made more Pythonic where appropriate. + +This [project](https://github.com/dsc/pyquery) is a fork of the [original](http://www.bitbucket.org/olauzanne/pyquery) +PyQuery developed by Olivier Lauzanne in 2008; it is maintained by [David Schoonover](mailto:dsc@less.ly). Feedback and bug +reports are both very welcome over on [github](https://github.com/dsc/pyquery/issues). + + +## Quickstart + +You can use the PyQuery class to load an xml document from a string, a lxml +document, from a file or from an url: + + >>> from pyquery import PyQuery as pq + >>> from lxml import etree + >>> import urllib + >>> d = pq("") + >>> d = pq(etree.fromstring("")) + >>> 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) + +Now `d` is like the `$` object in jQuery: + + >>> d("#hello") + [] + >>> p = d("#hello") + >>> print(p.html()) + Hello world ! + >>> p.html("you know Python rocks") + [] + >>> print(p.html()) + you know Python rocks + >>> print(p.text()) + you know Python rocks + +You can use some of the pseudo classes that are available in jQuery but that +are not standard in css such as `:first`, `:last`, `:even`, `:odd`, `:eq`, +`:lt`, `:gt`, `:checked`, `:selected`, and `:file`. + + >>> d('p:first') + [] + + +## Notes + + * PyQuery uses lxml for fast XML and HTML manipulation. + * This is not a library to produce or interact with JavaScript code. If +that's what you need, check out diff --git a/README.rst b/README.rst index ec3f64b..a50ff09 100644 --- a/README.rst +++ b/README.rst @@ -1,28 +1,21 @@ -pyquery: a jQuery-like library for Python +PyQuery: a jQuery-like library for Python ========================================= -pyquery allows you to make jQuery queries on html and xml documents. -The API is as much as possible the similar to jQuery. pyquery uses lxml for fast -xml and html manipulation. +PyQuery allows you to make `jQuery`_-style CSS-selector queries on XML/HTML documents. +The API is intended to match `jQuery's API`_ whenever possible, +though it has been made more Pythonic where appropriate. -This is not (or at least not yet) a library to produce or interact with -javascript code. I just liked the jQuery API and I missed it in python so I -told myself "Hey let's make jQuery in python". This is the result. +This `project`_ is a fork of the `original`_ PyQuery developed by Olivier Lauzanne in 2008; +it is maintained by `David Schoonover`_. Feedback and bug reports are +both very welcome over on `github`_. -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. -I can also be used for web scrapping or for theming applications with -`Deliverance`_. +.. _jQuery: http://jquery.com +.. _jQuery's API: http://api.jquery.com +.. _project: https://github.com/dsc/pyquery +.. _original: http://www.bitbucket.org/olauzanne/pyquery +.. _David Schoonover: mailto:dsc@less.ly +.. _github: https://github.com/dsc/pyquery/issues -The `project`_ is being actively developped on a mercurial repository on -Bitbucket. I have the policy of giving push access to anyone who wants it -and then to review what he does. So if you want to contribute just email me. - -Please report bugs on `github >> d('p:first') [] +Notes +===== + + * PyQuery uses lxml for fast XML and HTML manipulation. + * This is not a library to produce or interact with JavaScript code. If that's what you need, check out +