Tuesday, January 27, 2015

Dilbert RSS


Dilbert.com used to have an RSS feed, but has since removed this feature. Luckily, dilbert-rss was created by fredley, which allows anyone to create their own Dilbert RSS feed.

"dilbert-rssScrapes dilbert.com and generates an RSS feed.

Since dilbert.com nerfed their own RSS feed, I created a tool to replicate the old functionality. This is designed to be used on your own server, using cron to update it.
"

Usage

To use the dilbert-rss (assuming you want to store the RSS feed in /www/):
git clone https://github.com/fredley/dilbert-rss.git
cd dilbert-rss
python dilbert.py /www/dilbert.xml

Dependencies

Before you can use dilbert-rss, you will need to install two Python dependencies: BeautifulSoup and PyRSS2Gen
pip install BeautifulSoup PyRSS2Gen

BeautifulSoup and PyRss2Gen

On this topic, learning about the BeautifulSoup and PyRSS2Gen Python libraries were a benefit of using the dilbert-rss project. Both libraries can be used for a number of other useful projects. BeautifulSoup will parse an HTML page turning it into a usable Python object and PyRSS2Gen can be used to easily generate RSS feeds.

Oeey.com Dilbert Feed

An example of the output can be found here: http://dilbert.oeey.com/

Open the URL within an RSS viewer. If you don't have one handy, use Firefox to see the feed as a "Live Bookmarks" view. The content will be rendered. Most other browsers will just show the XML content.

With the above I created the following cronjob:
0 18 * * *   python /usr/local/bin/dilbert.py /www/dilbert/dilbert.xml
And the matching Apache configuration, with a default DirectoryIndex pointing to the XML feed:
<virtualhost>
    ServerName dilbert.oeey.com
    DirectoryIndex dilbert.xml
    DocumentRoot /www/dilbert
    ErrorLog logs/dilbert-error_log
    CustomLog logs/dilbert-access_log common
</virtualhost>



Update: Recently the Dilbert HTML layout changed. I had forked dilbert-rss and posted a suggested fix, to which fredley accepted the pull request.





No comments:

Post a Comment

Please be respectful.