1 # WWW::Scraper backend, replaces W3Search.pl functionality.
2 # Uses WWW::Scraper and associated modules instead of WWW::Search;
4 # Written by Don Armstrong <don@donarmstrong.com>
12 W3Scraper - blootbot plugin to do searches using WWW::Scraper
26 use vars qw ($VERSION);
31 my ($where,$what,$type) = @_;
33 # rip out the available engines by brute force.
34 my @matches = grep {/$where.pm/i and !/FieldTranslation/i and !/Re(sponse|quest)/i and !/TidyXML/i}
35 split /\n/, qx(ls /usr/share/perl5/WWW/Scraper);
38 $where = shift @matches;
42 &::msg($::who, "i don't know how to check '$where'");
46 return unless &::loadPerlModule("WWW::Scraper");
50 $scraper = new WWW::Scraper($where,$what);
52 if (not defined $scraper) {
53 &::msg($::who,"$where is an invalid search.");
59 while (my $result = $scraper->next_response()) {
60 next if not defined $result->url or not defined ${$result->url};
61 next if ((length ${$result->url}) > 80); #ignore long urls
65 $results .= ${$result->url};
66 last if ++$count > $maxshow;
69 $results = qq($where says "$what" is at $results [).
70 $scraper->approximate_result_count().
74 $results = qq($where was unable to find "$what");
76 &::performStrictReply($results);