3
import xml.etree.cElementTree as et
8
"media:content" : "media"
11
def multiple_replace(dic, text):
12
pattern = "|".join(map(re.escape, dic.keys()))
13
return re.sub(pattern, lambda m: dic[m.group()], text)
15
f = urllib2.urlopen("https://sourceforge.net/api/file/index/project-id/241033/mtime/desc/limit/40/rss")
17
xml = et.XML(multiple_replace(dic, f.read()))
22
for node in xml.iter("item"):
23
url = node.findtext("link")
24
for a in node.iter("media"):
25
hash = a.findtext("hash")
26
if "_full" in node.findtext("title") and url and hash:
28
print url + "|" + hash