A couple of people have emailed me about my "15" line perl script to use
with -S prog. Ok, I told a lie. It's really more like 23 lines. But I
could make is smaller if you need it in 15 lines ;)
I have content stored compressed in a MySQL database. This fetches it,
sets the title, uncompresses the content, and sends it off to swish to index.
It's kind of cool since with -S prog I can spider the site and index the
database all in one swish run:
./swish-e -c config -S prog -i ./spider.pl ./index_db.pl
#!/usr/local/bin/perl -w
use strict;
use DBI;
use Compress::Zlib;
my $dbh = DBI->connect('dbi:mysql:foo', '', '' );
my $sth = $dbh->prepare('select id, title, modified, content from table');
$sth->execute();
while ( my ($id, $title, $modified, $content) = $sth->fetchrow_array ) {
my $uncompressed = "<html><head><title>$title</title></head><body>"
. uncompress( $content )
. '</body></html>';
my $length = length $uncompressed;
print <<EOF;
Content-Length: $length
Last-Mtime: $modified
Path-Name: /show_page.cgi?id=$id
EOF
print $uncompressed;
}
Bill Moseley
mailto:moseley@hank.org
Received on Fri Nov 2 18:45:34 2001