Have you ever bumped into someone who looks like you? Pretty freaky. Well last night I had a similar experience with a post on another techBlog. Last night I received a nice note from Glenn Slaven that Good News Publishers (GNP) has extended their web services to provide RSS feeds for the English Standard Version Bible. And not only for select verses, but for a verse of the day.
Why the GNP didn’t email me still mystifies me a bit, but that said Glenn gets credit and kudos for offering the first cut at a Verse of the Day RSS Feed. As I told Glenn when I first visited his post on the topic, I thought I was visiting my own site!
That said, I also want to offer a couple of versions of it. Not because of anything lacking with Glenn’s cool code, but because I wanted to integrate the ESV RSS feed into a couple of past articles I posted on the topic, and see if I couldn’t easily mangle them to obviate my beloved but kludgy VerseScrape verse-of-the-day screen scraper.
Okay, first things first. For those of you who do not speak pure geek, an RSS feed is a text file structured in a format called XML. It is a machine-to-machine format, intended to facilitate diaglogs between computer programs on systems regardless of their computer language, operating system and hardware platform. This XML file is sent via the same mechanism web pages are delivered to your browser, the HTTP protocol. In fact, you can read RSS files with your browser, but as you’ll see, they’re not really organized for human consumption. One popular version of such a program is called an aggregator, which many people use to keep track of changes their favorite weblogs or web sites, without having to visit the site in their browser (until the site changes).
This is idea I had in mind when I wrote my article “Using Cron with LWP::Simple and XML::RSS to retrieve news feeds” back in March of this past year. With only a slight modification of the code offered on that page, I’m able to create a verse-of-the-day. Moreover, I can do it in a format that is similar to VerseScrape.
Some of the features in this code not found in Glenn’s SOLID EXAMPLE, is that the code below attempts to read the feed 10 times before giving up. This is good in those cases where burps occur online. Also, this version can accommodate situations in the future where more than one verse is added to the feed. I doubt that will happen, but its there just in case. Finally, I put in some code to strip out some extraneous TAB, LINEFEED and SPACE characters (known in computer parlance as whitespace) in the copyright statement/element delivered in the XML feed.
Now if this is TOO much code for you, here is a “LITE” version that also gets the job done. Based upon an article I wrote this past May entitled “Using XML::RSSLite to read feeds“, I offer this “esvfeedlite.pl.” It is similar to Glenn’s excellent approach, only this example uses the more liberal RSSLite module. Again, it takes care of some of the extraneous ‘whitespace’ issues in the copyright element, and accomodates multiple elements.
Remember to check those file permissions on the program files, AND on the output files. I use “chmod 755 esvfeed.pl” on the former and “chmod 644 dailyverse.inc.php” on the later, but your mileage may vary depending on how your server is set up and how your system is configured to access local files.
Tomorrow, I’ll show you how to do this in PHP … from CRON and/or the command line even!
Oh and Glenn, thanks so much for the email! It and your code are VERY appreciated!