Created
April 19, 2014 12:12
-
-
Save fxlv/11082732 to your computer and use it in GitHub Desktop.
This file contains 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/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