NAME

OurNet::Query - Scriptable queries with template extraction

SYNOPSIS

use OurNet::Query;

# Set query parameters
my ($query, $hits) = ('autrijus', 10);
my @sites = ('google', 'google'); # XXX: write more templates!
my %found;

# Generate a new Query object
my $bot = OurNet::Query->new($query, $hits, @sites);

# Perform a query
my $found = $bot->begin(\&callback, 30); # Timeout after 30 seconds

print '*** ' . ($found ? $found : 'No') . ' match(es) found.';

sub callback {
    my %entry = @_;
    my $entry = \%entry;

    unless ($found{$entry{url}}) {
        print "*** [$entry->{title}]" .
                 " ($entry->{score})" .
               " - [$entry->{id}]\n"  .
         "    URL: [$entry->{url}]\n";
    }

    $found{$entry{url}}++;
}

DESCRIPTION

This module provides an easy interface to perform multiple queries to internet services, and "wrap" them into your own format at once. The results are processed on-the-fly and are returned via callback functions.

Its interfaces resembles that of WWW::Search's, but implements it in a different fashion. While WWW::Search relies on additional subclasses to parse returned results, OurNet::Query uses site descriptors for search search engine, which makes it much easier to add new backends.

Site descriptors may be written in XML, Template toolkit format, or the .fmt format from the commercial Inforia Quest product.

CAVEATS

There's only google here, which is not acceptable. I should convert some 100 of popular web pages' site descriptors to .tt2 Real Soon Now.

This package is supposedly to magically turn your web pages built with Template Toolkit into web services overnight, but I'm not entirely sure of how to do it right.

There should be instructions of how to write templates in various formats.

SEE ALSO

OurNet::Site

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

COPYRIGHT

Copyright 2001 by Autrijus Tang <autrijus@autrijus.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html