Skip to content

Instantly share code, notes, and snippets.

@andreif
Created September 20, 2015 10:13
Show Gist options
  • Save andreif/c3480111638830812fcd to your computer and use it in GitHub Desktop.
Save andreif/c3480111638830812fcd to your computer and use it in GitHub Desktop.
from collections import OrderedDict
import json
from urllib.request import urlopen
import xml.etree.ElementTree as ET
xml = urlopen(url=url).read()
items = []
for item in ET.fromstring(xml).findall('channel')[0].findall('item'):
items.append(OrderedDict((i.tag, i.text) for i in item))
print(json.dumps(items, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment