1 # WWWSearch backend, with queries updating the is-db (optionally)
2 # Uses WWW::Search::Google and WWW::Search
3 # originally Google.pl, drastically altered.
12 my ($where, $what, $type) = @_;
13 my $retval = "$where can't find \002$what\002";
15 return unless &main::loadPerlModule("WWW::Search");
17 my @matches = grep { lc($_) eq lc($where) ? $_ : undef } @main::W3Search_engines;
19 $where = shift @matches;
21 &main::msg($main::who, "i don't know how to check '$where'");
24 my $Search = new WWW::Search($where);
25 my $Query = WWW::Search::escape_query($what);
26 $Search->native_query($Query,
29 # search_parse_debug => 2,
32 $Search->http_proxy($main::param{'httpProxy'}) if (&main::IsParam("httpProxy"));
33 my $max = $Search->maximum_to_retrieve(10); # DOES NOT WORK.
35 my (%results, $count, $r);
36 while ($r = $Search->next_result()) {
40 ### TODO: use array to preserve order.
41 if ($url =~ /^http:\/\/([\w\.]*)/) {
43 next if (exists $results{$hostname});
44 $results{$hostname} = $url;
46 &main::DEBUG("W3S: url isn't good? ($url).");
49 last if ++$count >= $maxshow;
52 if (scalar keys %results) {
53 $retval = "$where says \002$what\002 is at ".
54 join(' or ', map { $results{$_} } sort keys %results);
57 &main::performStrictReply($retval);