Hack #88. Automatically Collect Syndicated Feeds
Autodiscover RSS and Atom feeds as you browse, and then generate a subscriptions file you can import into any news aggregator.
Are you new to the world of syndication? If you've heard about using syndicated RSS or Atom feeds to keep up with your favorite sites in a news aggregator, here's an easy way to get started. Install the Feed Collector user script in this hack, and then simply visit the sites you visit regularly. Feed Collector will find the syndicated feeds automatically.
At the bottom-right corner of your browser window, you'll see a running total of the number of feeds collected so far. When you're ready, you're one click away from creating a subscriptions file that contains all the sites you've visited. The subscriptions file is in an XML format that's compatible with virtually every news aggregator.
Tip
For more information on syndicated feeds, visit http://www.atomenabled.org.
The Code
This user script runs on all web pages. The code is longer than most of the other hacks in this book, but it breaks down into four distinct parts:
The
getPageFeedsfunction autodiscovers syndicated feeds using a combination of XPath, regular expressions, JavaScript string functions, and elbow grease. Most syndication-enabled publishing software supports feed autodiscovery by embedding a special<link>element in the page that points to the page's syndicated feed.The functions
getHistoryCount, getHistoryItem, getAllHistoryItems, findHistoryItemByURL, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access