Created
February 21, 2011 03:23
-
-
Save eyeseast/836621 to your computer and use it in GitHub Desktop.
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
| from lxml.html import parse | |
| def get_feed(url): | |
| """ | |
| Find the first link to an XML feed (rss or atom) and return the URL | |
| """ | |
| page = parse(url).getroot() | |
| page.make_links_absolute() | |
| for link in page.head.findall('links'): | |
| if link.get('type', '').lower() in ('application/rss+xml', 'application/atom+xml'): | |
| return link.get('href') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment