Searching with Perl and WWW::Search

Here is an intro to multiple search engine queries:

#!/usr/bin/perl

@ses=("AltaVista", "Ask", "Lycos", "MSN", "Google", "Yahoo", "AlltheWeb");

$sq=''; #query goes here

$nq='250';

search();

sub search
{

foreach $se (@ses)
{

use WWW::Search;

open(FH, ">$se");
$search = new WWW::Search($se);
$search->native_query(WWW::Search::escape_query($sq));
$search->maximum_to_retrieve($nq);
while ($res = $search->next_result())
{
print FH $res->url;
print FH "\n";
}
close FH;
}

print "Queried @ses for $sq...check files for parsing pls...\n";
}

This is rather basic, but since AlltheWeb and Google backends don’t seem to be working properly, i won’t be parsing the results until i figure out what’s wrong with them, it will not be easy since i’ll need to mess with those nice modules but looking on the bright side of things it will bring me some more exp with Perl itself.Anyway this is another example of the power of scripting languages like Perl and now it’s time to head out to the beach.

Posted on August 11, 2009 at 15:28 by Faka Kente · Permalink
In: Faka · Tagged with: 

Leave a Reply