pyquery.ajax – PyQuery AJAX extension

You can query some wsgi app if WebOb is installed (it’s not a pyquery dependencie). IN this example the test app returns a simple input at / and a submit button at /submit:

>>> d = pq('<form></form>', app=input_app)
>>> d.append(d.get('/'))
[<form>]
>>> print d
<form><input name="youyou" type="text" value=""/></form>

The app is also available in new nodes:

>>> d.get('/').app is d.app is d('form').app
True

You can also request another path:

>>> d.append(d.get('/submit'))
[<form>]
>>> print d
<form><input name="youyou" type="text" value=""/><input type="submit" value="OK"/></form>

If restkit is installed, you are able to get url directly with a HostProxy app:

>>> a = d.get('http://packages.python.org/pyquery/')
>>> a
[<html>]

You can retrieve the app response:

>>> print a.response.status
200 OK

The response attribute is a WebOb Response

Api

class pyquery.ajax.PyQuery(*args, **kwargs)[source]
get(path_info, **kwargs)[source]

GET a path from wsgi app or url

post(path_info, **kwargs)[source]

POST a path from wsgi app or url

Table Of Contents

Previous topic

Scraping

Next topic

Tips

This Page