python - Replace HTML tags preserving their content using lxml -



python - Replace HTML tags preserving their content using lxml -

i have html content (without html, body , head etc. tags). need strip style info tags , replace div tags p tags.

i striping style info using:

from lxml.html.clean import cleaner homecoming cleaner(style=true).clean_html(html)

how can replace div tags p tags while preserving content of div tags (content of div tags should in new p tags).

html = html.replace("<div>", "<p>") html = html.replace("</div>", "</p>")

you full-blown html parsing , generating, above ok this.

python lxml

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -