python: html writer?
With jquery it's very easy to insert some element inside another element using the selector technology, I am wondering if there is any python library that can do things similar with jquery, the reason is I want server side python program to produce the static pages, which needs to parse the html and insert something into it.
Or other alterna开发者_运维技巧tive, not in python language at all?
EDIT: To be clear, I want to use python to write below program:
h = html.parse('temp.html')
h.find('#idnum').html('<b>my html generated</b>')
h.close()
It sounds like pyquery works very similarly to what you're looking for.
BeautifulSoup can modify the parse tree see http://www.crummy.com/software/BeautifulSoup/documentation.html#Modifying%20the%20Parse%20Tree
lxml
lxml is a Pythonic binding for the libxml2 and libxslt libraries. It is unique in that it combines the speed and feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the well-known ElementTree API.
精彩评论