Skip to content

Instantly share code, notes, and snippets.

@maakuth
Last active August 29, 2015 14:20
Show Gist options
  • Save maakuth/9f9d15ecb508affd0395 to your computer and use it in GitHub Desktop.
Save maakuth/9f9d15ecb508affd0395 to your computer and use it in GitHub Desktop.
try:
import lxml.etree as ET
except:
import xml.etree.ElementTree as ET
import requests
def getRss():
lang = "fi"
url = "http://feeds.yle.fi/areena/v1/series/1-1440981.rss?lang={0}".format(lang)
return requests.get(url).content
def getAudioUrl():
channel = "Yle Radio Suomi"
rssdoc = getRss()
#ET.register_namespace("media", "http://search.yahoo.com/mrss/")
rssEt = ET.fromstring(rssdoc)
prefixes = {"media": "http://search.yahoo.com/mrss/"}
xpath = "./rss/channel/item[media:credit='{0}'][1]/enclosure".format(channel)
for elem in rssEt.findall(xpath, namespaces=prefixes):
print (elem)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment