Skip to content

Instantly share code, notes, and snippets.

@maria-aguilera
Forked from Averroes/example.py
Created July 31, 2024 09:04
Show Gist options
  • Save maria-aguilera/6c2c53895e68467d13a61d9f225c558a to your computer and use it in GitHub Desktop.
Save maria-aguilera/6c2c53895e68467d13a61d9f225c558a to your computer and use it in GitHub Desktop.
parsing simple xml data
from urllib.request import urlopen
from xml.etree.ElementTree import parse
# Download the RSS feed and parse it
u = urlopen('http://planet.python.org/rss20.xml')
doc = parse(u)
# Extract and output tags of interest
for item in doc.iterfind('channel/item'):
title = item.findtext('title')
date = item.findtext('pubDate')
link = item.findtext('link')
print(title)
print(date)
print(link)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment