# Blogger-Atom-Feeds -> Blogbeitraege 3300 (Datum, Titel, HTML, Labels, URL) import sys, json, re, html import xml.etree.ElementTree as ET ns = {'a': 'http://www.w3.org/2005/Atom'} out = [] for f in sys.argv[1:-1]: for e in ET.parse(f).getroot().findall('a:entry', ns): url = next(l.get('href') for l in e.findall('a:link', ns) if l.get('rel') == 'alternate') out.append({'published': e.findtext('a:published', namespaces=ns), 'title': e.findtext('a:title', namespaces=ns), 'url': url.replace('http://', 'https://'), 'labels': [c.get('term') for c in e.findall('a:category', ns)], 'html': e.findtext('a:content', namespaces=ns)}) out = [o for o in out if o['published'].startswith('3300')] out.sort(key=lambda o: o['published']) json.dump(out, open(sys.argv[-1], 'w'), ensure_ascii=False, indent=1) print(len(out)) for o in out: print(o['published'][:16], o['title'][:60], '|', ', '.join(o['labels']))