huuuuuup !!!
Working on a self defined BIG project. Optimising search on top of search engines. Below is initial working code ;)
[root@viral mywebsite]# cat index.html search.php search.pl
Hi, this is homepage for Management System
Product
Job work
You want to G00gle something My Sophisticated search engine. It mixes up Google, Yahoo! and Alta Vista searches.
Enter Your query and Click Search
You want to search "
" using search engine
eval('print "Hello from perl! "');
#$perl->require("./search.pl");
#$perl->require("/var/www/html/mywebsitednfssearch.pl");
#$perl->eval('require LWP::UserAgent');
#$perl->eval('my $ua = LWP::UserAgent->new');
#$perl->eval('$response = $ua->get("
http://www.google.com/#hl=en&q=$search_query")');
#$perl->eval('print $response->content');
?>
#!/usr/bin/perl -s -w
use URI::Escape;
use LWP::UserAgent;
foreach my $word (@ARGV) {
next unless length $word; # sanity-checking
my $url = '
http://www.altavista.com/sites/search/web?q=%22'
. uri_escape($word) . '%22&kl=XX';
my ($content, $status, $is_success) = do_GET($url);
if (!$is_success) {
print "Sorry, failed: $status\n";
} elsif ($content =~ m/>AltaVista found ([0-9,]+) results?/) { # like "1,952"
print "Alta Vista : $word : $1 matches\n";
} else {
print "$word: Page not processable, at $url\n";
}
sleep 2; # Be nice to AltaVista's servers!!!
#Now search same for Google
my $url = '
http://www.google.com'
# . uri_escape($word) . '&fr=sfp&fr2=&iscqry=';
$url->query_form('q' => $word);
print $url;
my ($content, $status, $is_success) = do_GET($url);
if (!$is_success) {
print "Sorry, failed: $status\n";
} elsif ($content =~ m/>of ([0-9,]+) for/) { # like "1,952"
print "Google : $word : $1 matches\n";
} else {
print "$word: Page not processable, at $url\n";
}
sleep 2; # Be nice to Google's servers!!!
}
# And then my favorite do_GET routine:
use LWP; # loads lots of necessary classes.
my $browser;
sub do_GET {
$browser = LWP::UserAgent->new unless $browser;
my $resp = $browser->get(@_);
return ($resp->content, $resp->status_line, $resp->is_success, $resp)
if wantarray;
return unless $resp->is_success;
return $resp->content;
}