Skip to content

Instantly share code, notes, and snippets.

@fxlv
Created April 19, 2014 12:12
Show Gist options
  • Save fxlv/11082732 to your computer and use it in GitHub Desktop.
Save fxlv/11082732 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Get a url from stdin, parse it and return a list of potential rss/xml/atom feed URLs in it
from bs4 import BeautifulSoup
import requests
import sys
def main():
stdin=sys.stdin.readlines()[0].strip()
url=stdin
req=requests.get(url)
soup=BeautifulSoup(req.content)
for url in soup.findAll("link",type="application/rss+xml"):
url=url["href"].lower()
print url
if __name__ == "__main__":
try:
main()
except Exception as e:
print "Something exploded"
print e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment