Python: Convert quote in HTML content not HTML tags -
i have piece of html this:
<pre class="script">template("main/globalshared");</pre> <pre class="script"> var link = '/draft/tracker_1.1'; if (wiki.pageexists(link)) { <div class="version"> web.link(wiki.uri(link), 'version 1.1') </div> } </pre> i need convert this:
<pre class="script">template("main/globalshared");</pre> <pre class="script"> var link = '/draft/tracker_1.1'; if (wiki.pageexists(link)) { <div class="version"> web.link(wiki.uri(link), 'version 1.1') </div> } </pre> i have been fiddling regular expressions can't seem close. think choice wrong.
can point me in right direction if possible?
use html parser instead, replace quotes .replace('"', '"').
beautifulsoup makes task easy:
from bs4 import beautifulsoup soup = beautifulsoup(htmlsource) string in soup.strings: string.replace_with(string.replace('"', '"')) htmlsource = str(soup)
Comments
Post a Comment