Post RSS Headlines on Your Site

Place other sites’ syndicated headlines on your own pages, periodically.

Including syndicated newsfeeds is a nice way of adding some compelling content to your site. The problem is that sometimes the news feed gets overrun during heavy news days, goes offline, and/or suffers a host of other connectivity issues. These problems make your site load slowly, because the software holds your user hostage while the feed retrieval portion of the application waits to time out.

A simple way around this problem is to use a program that periodically retrieves the feed and slices and dices it into an easy-to-include file on your host. Doing this achieves five goals:

  • User page loads are not penalized when feeds go down.

  • Failures to connect do not harm the existing include file.

  • Multiple attempts to read the feed do not penalize the user.

  • Feeds can be mirrored for local/private use.

  • Content can be formatted to taste.

The Code

This is a little program (getap.pl) I wrote to repurpose news from an AP Wire feed:

#!/usr/bin/perl -w # ----------------------------------------------------------------------- # copyright Dean Peters © 2003 - all rights reserved # http://www.HealYourChurchWebSite.org # ----------------------------------------------------------------------- # # getap.pl is free software. You can redistribute and modify it # freely without any consent of the developer, Dean Peters, if and # only if the following conditions are met: # # (a) The copyright info and links ...

Get XML Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.