Skip to content

Instantly share code, notes, and snippets.

@docblades
Created January 16, 2011 05:06
Show Gist options
  • Save docblades/781582 to your computer and use it in GitHub Desktop.
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.
#!/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