Manipulating ------------ .. >>> from pyquery import PyQuery as pq You can also add content to the end of tags:: >>> d = pq('

you know Python rocks

') >>> d('p').append(' check out reddit') [] >>> print(d)

you know Python rocks check out reddit

Or to the beginning:: >>> p = d('p') >>> p.prepend('check out reddit') [] >>> print(p.html()) check out reddityou know ... Prepend or append an element into an other:: >>> d = pq('') >>> p.prependTo(d('#test')) [] >>> print(d('#test').html())

>> p.insertAfter(d('#test')) [] >>> print(d('#test').html()) python ! Or before:: >>> p.insertBefore(d('#test')) [] >>> print(d('body').html())

... Doing something for each elements:: >>> p.each(lambda i, e: pq(e).addClass('hello2')) [] Remove an element:: >>> d = pq('

Yeah!

python rocks !

') >>> d.remove('p#id') [] >>> d('p#id') [] Remove what's inside the selection:: >>> d('p').empty() [

] And you can get back the modified html:: >>> print(d)

You can generate html stuff:: >>> from pyquery import PyQuery as pq >>> print(pq('

Yeah !
').addClass('myclass') + pq('cool'))
Yeah !
cool Remove all namespaces:: >>> d = pq('') >>> d [<{http://example.com/foo}foo>] >>> d.remove_namespaces() []