Last active
August 29, 2015 14:20
-
-
Save maakuth/9f9d15ecb508affd0395 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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