OpenExoplanetCatalogue/open_exoplanet_catalogue — pull request #278 by Sol-d (2014-06-23 19:30:52+00:00)
Title: Added hint for python version

The script only runs under python 2.x.
python 3.x:
# python 3.x
import xml.etree.ElementTree as ET, urllib.request, gzip, io
url = "https://github.com/OpenExoplanetCatalogue/oec_gzip/raw/master/systems.xml.gz"
oec = ET.parse(gzip.GzipFile(fileobj=io.BytesIO(urllib.request.urlopen(url).read())))

# Output mass and radius of all planets
for planet in oec.findall(".//planet"):
print(planet.findtext("mass"), planet.findtext("radius"))

# Find all circumbinary planets
for planet in oec.findall(".//binary/planet"):
print(planet.findtext("name"))

# Output distance to planetary system (in pc, if known) and number of planets in system
for system in oec.findall(".//system"):
print(system.findtext("distance"), len(system.findall(".//planet")))