Wednesday, September 7, 2016

Generate HTML static files from Wordpress WXR using Python

Tested on Python 3.5 (32 bit) for Windows

It is fairly common knowledge that plugins are available to export Wordpress into static files. However, to have your static content generated in far more flexible manner, it's always programming to the rescue.

The script is adapted from the original code found in Jon Thysell's excellent WXR to HTML article.

I modified the original script slightly to download images that are included in each article, as well as saving articles as individual files in YYYY\M\xxx.html format.

This script would take 1 argument as input. It expects the full path to the Wordpress WXR export file (in xml format). The WXR file can be exported by going to Wordpress Admin -> Tools -> Export. I used a full export.

Related Posts Plugin for WordPress, Blogger...