git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@751
c11ca15a-4712-0410-83d8-
924469b57eb5
Lycos Magellan PLweb SFgate Simple Verity Google z);
$W3Search_regex = join '|', @W3Search_engines;
Lycos Magellan PLweb SFgate Simple Verity Google z);
$W3Search_regex = join '|', @W3Search_engines;
sub W3Search {
my ($where, $what, $type) = @_;
sub W3Search {
my ($where, $what, $type) = @_;
return unless &::loadPerlModule("WWW::Search");
eval {
return unless &::loadPerlModule("WWW::Search");
eval {
- $Search = new WWW::Search($where);
+ $Search = new WWW::Search($where, agent_name => 'Mozilla/4.5');
};
if (!defined $Search) {
};
if (!defined $Search) {
my $Query = WWW::Search::escape_query($what);
$Search->native_query($Query,
my $Query = WWW::Search::escape_query($what);
$Search->native_query($Query,
# search_debug => 2,
# search_parse_debug => 2,
# search_debug => 2,
# search_parse_debug => 2,
);
$Search->http_proxy($::param{'httpProxy'}) if (&::IsParam("httpProxy"));
);
$Search->http_proxy($::param{'httpProxy'}) if (&::IsParam("httpProxy"));
- my $max = $Search->maximum_to_retrieve(10); # DOES NOT WORK.
+ #my $max = $Search->maximum_to_retrieve(10); # DOES NOT WORK.
- my (%results, $count, $r);
+ my (@results, $count, $r);
+ $retval = "$where says \002$what\002 is at ";
while ($r = $Search->next_result()) {
my $url = $r->url();
while ($r = $Search->next_result()) {
my $url = $r->url();
-
- ### TODO: fix regex.
- ### TODO: use array to preserve order.
- if ($url =~ /^http:\/\/([\w\.]*)/) {
- my $hostname = $1;
- next if (exists $results{$hostname});
- $results{$hostname} = $url;
- } else {
- &::DEBUG("W3S: url isn't good? ($url).");
- }
-
+ $retval .= ' or ' if ($count > 0);
+ $retval .= $url;
last if ++$count >= $maxshow;
}
last if ++$count >= $maxshow;
}
- if (scalar keys %results) {
- $retval = "$where says \002$what\002 is at ".
- join(' or ', map { $results{$_} } sort keys %results);
- }
-
&::performStrictReply($retval);
}
&::performStrictReply($retval);
}