Created
January 25, 2012 09:05
-
-
Save dietmarw/1675530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pyquery import PyQuery as pq | |
import codecs | |
def convert_image(i, node): | |
print node | |
node = pq(node) | |
uri = node.attr("src") | |
if uri: | |
print "converting", uri | |
src = "".replace("M", "X") | |
node.attr("src", src) | |
with codecs.open("old-html-tmp/Modelica.Fluid.html", encoding="utf-8") as fh: | |
html = fh.read() | |
doc = pq(html) | |
doc.find("img").each(convert_image) | |
print doc.__html__() # __html__ method avoids escaping -- TODO: retain doctype |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment