O'Reilly logo

Building Tag Clouds in Perl and PHP by Jim Bumgardner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collecting del.icio.us Tags in Perl

Our second script, makeDeliciousTags.pl, produces a list of tags from the most recent entries in your del.icio.us account. If you don't have a del.icio.us account, you can either get one (it's free) or use my username (jbum) as I'm doing in these examples. You can view my del.icio.us bookmarks at the following URL: http://del.icio.us/jbum .

To run the script, enter its name on the command line, followed by the del.icio.us username that you want to collect tags for, like so:

makeDeliciousTags.pl jbum

In this example, the script will produce a file called deliciousTags_jbum.pl.

This script is a little different, since it is parsing an RSS file. Let's examine it in more detail.

#!/usr/bin/perl

use HTTP::Cache::Transparent;
use LWP::Simple;
use Data::Dumper;
use XML::RSSLite;

These lines load the CPAN modules we are going to use. In addition to the modules used in the previous script, we add the XML::RSSLite module, which enables us to parse the XML data in an RSS feed.

use strict;
use warnings;

As in the previous script, the above lines turn on strict warning messages, and initialize the caching mechanism.

HTTP::Cache::Transparent::init( {
  BasePath => './cache',
  NoUpdate => 30*60
} );

The above lines specify a local caching directory, as before, and insure that we don't access the web site more than once every 30 minutes. This precaution not only makes your script more efficient, it is the recommended access policy at del.icio.us. If you attempt to read the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required