Created
January 16, 2011 05:06
-
-
Save docblades/781582 to your computer and use it in GitHub Desktop.
Takes rss url(s) as an argument, and extracts torrent urls from them.
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
#!/usr/bin/python | |
import xml.dom.minidom as minidom | |
from urllib import urlopen | |
import argparse | |
parser = argparse.ArgumentParser(description="Given a URL to an RSS torrent feed, extracts the urls.") | |
parser.add_argument('url', nargs='*', help='url of an RSS feed') | |
def getText(nodeList): | |
retText = [] | |
for node in nodeList: | |
if node.nodeType == node.TEXT_NODE: | |
retText.append(node.data) | |
return "".join(retText) | |
def process_feed(url): | |
rssData = urlopen(url) | |
dom = minidom.parse(rssData) | |
items = dom.getElementsByTagName('item') | |
for item in items: | |
link = item.getElementsByTagName("link")[0] | |
print getText(link.childNodes) | |
urlList = parser.parse_args().url | |
for url in urlList: | |
process_feed(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment