All pastes #46736 Raw Edit

Anonymous

public text v1 · immutable
#46736 ·published 2006-03-23 20:33 UTC
rendered paste body
sub answer { 
my $self = shift; 
my $cmdline = join("?", @_);
my $ua = LWP::UserAgent->new( 'agent' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 Firebird/0.7');
$cmdline =~ s/\+/%2b/g;
$cmdline =~ s/\?/+/g;

$cmdline = "http://www.google.com/search?q=" . $cmdline;

print "Checking $cmdline\n";

my $response = $ua->get($cmdline);

my $html = $response->content;

$html =~ m/<td valign=top>(.*?href=.*?oi=(def|answers).*?)<\/td>/;
$html = $1.$2.$3;

$html =~ s|&#8212;|--|g;
$html =~ s|&raquo;||g;
$html =~ s|<br>| -- |g;
$html =~ s|\<.*?\>||g;
$html =~ s| - More sources||;

print "$html\n";

return $html;
}