title: Is there any good python css inlining module for html in the wild?
body: <p>I would like to inline arbitrary webpages using python. I've tried a couple of libraries out there but none of them works well on "real" content, such as the nytimes to take a complex example. Also, I want the external stylesheets to be inlined too. Do you have any advice? Here is my test code at the moment:</p>
  
  <pre><code>import requests
  import codecs
  from html5tidy import tidy
  
  url = "http://www.nytimes.com/"
  
  r = requests.get(url)
  src = tidy(r.text)
  
  
  from pypremailer import Premailer
  p = Premailer(src)
  output = p.premail()
  f = open("/tmp/pypremailer.html", "w")
  f.write(output)
  f.close()
  
  from premailer import transform
  output = transform(src)
  f = open("/tmp/premailer.html", "w")
  f.write(output)
  f.close()
  
  import pynliner
  output = pynliner.fromString(src)
  f = open("/tmp/pynliner.html", "w")
  f.write(output)
  f.close()
  
  from inlinestyler.utils import inline_css
  output = inline_css(src)
  f = open("/tmp/inlinestyler.html", "w")
  f.write(output)
  f.close()
  </code></pre>
  
  <p>thanks</p>