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
Post a Comment