Bookmarked Blogroll by Dan MacKinlay (danmackinlay.name)

Make your own automatic blogroll

This is the script I use to generate a blogroll from my OPML:

#! /usr/bin/env python3
"""
Parse OPML into markdown.
"""
import sys
import re
from xml.etree import ElementTree


def main(fname):
    with open(fname, 'r', encoding='utf8') as fp:
        tree = ElementTree.parse(fp)
    for cat_node in tree.find('body').findall('outline'):
        print("\n## {}\n".format(cat_node.get('title')))
        for node in cat_node.findall('outline'):
            name = node.attrib.get('text')
            feedurl = node.attrib.get('xmlUrl')
            url = node.attrib.get('htmlUrl')
            print("* [{}]({}) ([feed]({}))".format(name, url, feedurl))


if __name__ == "__main__":
    main(*sys.argv[1:])

Published by

Chris Aldrich

I'm a biomedical and electrical engineer with interests in information theory, complexity, evolution, genetics, signal processing, IndieWeb, theoretical mathematics, and big history. I'm also a talent manager-producer-publisher in the entertainment industry with expertise in representation, distribution, finance, production, content delivery, and new media.

Leave a Reply

Your email address will not be published. Required fields are marked *