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.

One thought on “”

  1. 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’): … Continue reading

Mentions

Leave a Reply

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

To respond to a post on this site using your own website, create your post making sure to include the (target) URL/permalink for my post in your response. Then enter the URL/permalink of your response in the (source) box and click the 'Ping me' button. Your response will appear (possibly after moderation) on my page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)