So I was wondering if anyone knew a simple tool/script to output (phoenix) html pages to static html?
It definitely doesn’t need to be in elixir, a simple browser tool is ok as well.
The reason I’m looking at elixir is that it’s a phoenix website, but I know that doesn’t really matter.
It’s quite a lot of pages, so not something I want to do manually.
GNU Wget specifically with -k and -r options? I’ve been using it for like 20 years on occasion to create mirrors of web sites in static versions.
If you control the app you could also write a plug that’d snapshot rendered pages to file.
wget is definitely an option.
Any hints on the plug?
wget -m -k -p https://site.here is awesome. Thanks!
Creating a Mirror of a Website
To create a mirror of a website with
wget, use the
wget -m https://example.com
If you want to use the downloaded website for local browsing, you will need to pass a few extra arguments to the command above.
wget -m -k -p https://example.com
-k option will cause
wget to convert the links in the downloaded documents to make them suitable for local viewing. The
-p option will tell
wget to download all necessary files for displaying the HTML page
Ah my memory may have not served me well.
-m -k -p yes, these are the options you want I think.
As of the Plug idea, I am not entirely sure if that’d work as plug or registering Cowboy response handler would be needed. But basically it’d be like “full page caching” in Rails, where the returned HTML is being saved to disk. I suspect you may need to use Plug.Conn.register_before_send/2 and capture and save the response to file before sending it to customer. Definitely this can be wonky and problematic.