Best way to programmatically save a webpage to a Static HTML File

后端 未结 2 1270
广开言路
广开言路 2021-02-15 15:44

The more research I do, the more grim the outlook becomes.

I am trying to Flat Save, or Static Save a webpage with Python. This means merging all the styles to inline pr

2条回答
  •  北海茫月
    2021-02-15 16:24

    After walking away for a while, I managed to install a ruby library that flattens the CSS much much better than anything else I've used. It's the library behind the very slow web interface here http://premailer.dialect.ca/

    Thank goodness they released the source on Github, it's the best hands down. https://github.com/alexdunae/premailer

    It flattens styles, creates absolute urls, works with a URL or string, and can even create plain text email templates. Very impressed with this library.

    Update Nov 2013

    I ended up writing my own bookmarklet that works purely client side. It is compatible with Webkit and FireFox only. It recurses through each node and adds inline styles then sends the flattened HTML to the clippy.in API to save to the user's dashboard.

    Client Side Bookmarklet

提交回复
热议问题