2

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 alternative, 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()

3 Answers 3

3

It sounds like pyquery works very similarly to what you're looking for.

Sign up to request clarification or add additional context in comments.

Comments

3

BeautifulSoup can modify the parse tree see http://www.crummy.com/software/BeautifulSoup/documentation.html#Modifying%20the%20Parse%20Tree

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.