# $File: //depot/OurNet-Query/Query.pm $ $Author: autrijus $ # $Revision: #4 $ $Change: 1925 $ $DateTime: 2001/09/28 15:12:40 $ package OurNet::Query; require 5.005; $OurNet::Query::VERSION = '1.56'; use strict; use OurNet::Site; use HTTP::Request::Common; use LWP::Parallel::UserAgent; =head1 NAME OurNet::Query - Scriptable queries with template extraction =head1 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}}++; } =head1 DESCRIPTION This module provides an easy interface to perform multiple queries to internet services, and I 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 I's, but implements it in a different fashion. While I relies on additional subclasses to parse returned results, I uses I for search search engine, which makes it much easier to add new backends. Site descriptors may be written in XML, I