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

后端 未结 2 1286
广开言路
广开言路 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:07

    It sounds like inline styles might be a deal-breaker for you, but if not, I suggest taking another look at Evernote Web Clipper. The desktop app has an Export HTML feature for web clips. The output is a bit messy as you'd expect with inline styles, but I've found the markup to be a reliable representation of the saved page.

    Regarding inline vs. external styles, for something like this I don't see any way around inline if you're doing a lot of pages from different sites where class names would have conflicting style rules.

    You mentioned that Web Clipper uses iFrames, but I haven't found this to be the case for the HTML output. You'd likely have to embed the static page as an iFrame if you're re-publishing on another site (legally I assume), but otherwise that shouldn't be an issue.

    Some automation would certainly help so you could go straight from the browser to the HTML output, and perhaps for relocating the saved images to a single repo with updated src links in the HTML. If you end up working on something like this, I'd be grateful to try it out myself.

提交回复
热议问题