sohaib69
asked on
perl search engine
dear sir, i need a perlscript by which i will search google.com search engine thru my web site, and
then the result will show on my web site just the results, how I am going to tdo this. could you please
tell me the perl or cgi script in order to search like that. Thanks.
then the result will show on my web site just the results, how I am going to tdo this. could you please
tell me the perl or cgi script in order to search like that. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi there, ihave install that WWW:SEARCH MODULE, and now after when i run that script it gave me internal server error , and my error log says :-
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:39 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:40 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:41 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:42 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:43 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:44 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go ogle.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:39 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:40 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:41 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:42 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:43 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at google.cgi line 5.
[Sat Jun 2 20:12:44 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm...
Yes - you need to install it first.
Get it from:
http://search.cpan.org/search?dist=WWW-Search-Google
Yes - you need to install it first.
Get it from:
http://search.cpan.org/search?dist=WWW-Search-Google
Install this too:
http://search.cpan.org/search?dist=Bundle-WWW-Search-ALL
http://search.cpan.org/search?dist=Bundle-WWW-Search-ALL
ASKER
I install that module and its giving me that error Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:03 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:06 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:07 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:08 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:09 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38 6-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_per$
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:10 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go og.cgi
One more thing when I do perl -v i got some error, on my server it says..
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US",
LANG = "en_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I think thats why its not coming up, what you think anyway how to get rid of that error.
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:03 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:06 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:07 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:08 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:09 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
Can't locate WWW/Search.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i38
BEGIN failed--compilation aborted at goog.cgi line 5.
[Sat Jun 2 20:27:10 2001] [error] [client 63.100.208.117] Premature end of script headers: /home/admin/www/cgi-bin/go
One more thing when I do perl -v i got some error, on my server it says..
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US",
LANG = "en_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I think thats why its not coming up, what you think anyway how to get rid of that error.
ASKER
I have solove that LC_ALL problem and i have also install those modules which are
WWW-Search-Google-2.21.tar .gz
Bundle-WWW-Search-ALL-1.17 .tar.gz
Its worked now but the thing is , its giving me result like just
http://free.prohosting.com/ http://www.xoom.com/ http://www.sendmail.org/virtual-hosting.html http://www.advancedaccess.com/ http://www.webhostdir.com/ http://www.fortunecity.com/ http://www.atfreeweb.com/ http://cedant.com/ http://www.nextmill.net/ http://www.hostingsolutions.net/ http://www.zolt.net/ http://www.onlinebusiness.com/shops/_internet_services/BEST_free_web_pages.shtml http://home.verio.com/products/hosting/index.cfm http://home.verio.com/ http://www.rackspace.com/index.php http://www.zdnet.com/business/filters/webhosting/homepage/ http://www.zdnet.com/devhead/filters/0,9429,2138312,00.html http://www.web-hosting-guide.com/ http://www.dynamichosting.com/ http://www.mainehost.com/ http://www.hosting.cz/ http://www.iweb-hosting.com/ http://www.web-hosting.com/ http://danworld.net/hosting.shtml http://www.pmsicom.net/ http://www.pcawebdesign
I cant click on link and its not even showing me any numbers like you know i want something like
1 - http://www.wcws.net
and then next page to see next result , how is that possible, its just messing up every thing after search you know..
Thanks,
WWW-Search-Google-2.21.tar
Bundle-WWW-Search-ALL-1.17
Its worked now but the thing is , its giving me result like just
http://free.prohosting.com/ http://www.xoom.com/ http://www.sendmail.org/virtual-hosting.html http://www.advancedaccess.com/ http://www.webhostdir.com/ http://www.fortunecity.com/ http://www.atfreeweb.com/ http://cedant.com/ http://www.nextmill.net/ http://www.hostingsolutions.net/ http://www.zolt.net/ http://www.onlinebusiness.com/shops/_internet_services/BEST_free_web_pages.shtml http://home.verio.com/products/hosting/index.cfm http://home.verio.com/ http://www.rackspace.com/index.php http://www.zdnet.com/business/filters/webhosting/homepage/ http://www.zdnet.com/devhead/filters/0,9429,2138312,00.html http://www.web-hosting-guide.com/ http://www.dynamichosting.com/ http://www.mainehost.com/ http://www.hosting.cz/ http://www.iweb-hosting.com/ http://www.web-hosting.com/ http://danworld.net/hosting.shtml http://www.pmsicom.net/ http://www.pcawebdesign
I cant click on link and its not even showing me any numbers like you know i want something like
1 - http://www.wcws.net
and then next page to see next result , how is that possible, its just messing up every thing after search you know..
Thanks,
ASKER
Hi there, i have that following script but the thing is when ever I run that on my server its just give me powered by some one else, how I am going to get rid of that, u can see how I want my script to be, like the script is :-
========================== ========== ========== ========== ===
#!/usr/bin/perl
#
# Zygit Co-Branding
# Free Style
# Copyright (c) 2001 Zygit Networks
#
#
use LWP::Simple;
use LWP::UserAgent;
&cgi_header;
&cgi_receive;
# The location of your header and footer (full path not the address)
$header = "/home/www/header.html";
$footer = "/home/www/footer.html";
# If you rename the script, be sure to update this line. Use the
# URL address for this (http://www.you.ext/cgi-bin/search/metasearch.cgi)
$script_url = "metasearch.cgi";
# DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU ARE DOING!
#------------------------- ---------- ---------- --------
$startpage = $FORM{startpage};
$search = $FORM{search};
$skip = $FORM{skip};
if ($startpage eq "") { $startpage = 1 ; }
open (HEADER, "$header");
while (<HEADER>) { print; }
print <<EOF;
<center>
<form action="$script_url"><inpu t type=text name=search value=$search><input type=submit value=Search></form>
<br><a name=top>
</center>
EOF
if ($search eq "") {
exit(0);
} else {
$url = "http://www.zygit.com/cgi-bin/search/metasearch.pl?etype=web&search=$search&logfile=searches&startpage=$startpage";
}
my $ua = new LWP::UserAgent;
my $res = $ua->request(HTTP::Request->new(GET => $url));
my $content = $res->content;
@page = split(/\n/,$content);
for (@page){
$_ =~ s/#99CCCC/$header_color/g;
$_ =~ s/metasearch.pl/$script_ur l/g;
$_ =~ s/name="query"/name=search /g;
if ($_ =~ /<!--pull -->/) { $print = "on"; }
if ($_ =~ /<!--stop -->/) { $print = "off"; }
if ($print eq "on") { print "$_\n"; }
}
print <<EOF;
<center>
<form action="$script_url"><inpu t type=text name=search> <input type=submit value=Search></form>
<br><a name=top>
</center>
EOF
sub parse_form {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9] )/pack("C" , hex($1))/eg;
$FORM{$name} = $value;
}
}
open (FOOTER, "$footer");
while (<FOOTER>) { print; }
# DO NOT TOUCH THIS!
sub cgi_header {
print "Content-type: text/html\n";
print "\n" unless ($FORM{'next-url'});
}
sub cgi_receive {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $incoming, $ENV{'CONTENT_LENGTH'});
}
else {
$incoming = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $incoming);
foreach (@pairs) {
($name, $value) = split(/=/, $_);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([A-F0-9][A-F0-9])/pack ("C", hex($1))/gie;
$value =~ s/%([A-F0-9][A-F0-9])/pack ("C", hex($1))/gie;
#### Strip out semicolons unless for special character
$value =~ s/;/$$/g;
$value =~ s/&(\S{1,6})$$/&\1;/g;
$value =~ s/$$/ /g;
$value =~ s/\|/ /g;
$value =~ s/^!/ /g; ## Allow exclamation points in sentences
#### Skip blank text entry fields
next if ($value eq "");
#### Check for "assign-dynamic" field names
#### Mainly for on-the-fly input names, especially checkboxes
if ($name =~ /^assign-dynamic/) {
$name = $value;
$value = "on";
}
#### Allow for multiple values of a single name
$FORM{$name} .= ", " if ($FORM{$name});
$FORM{$name} .= $value;
}
}
========================== ========== ========== ========== ===
you can see the example at
http://www.wcws.net/metasearch.cgi?search=saasoh
I want something like that . .
could you please help me but the thing is I dont want anything like Powered by: Zygit Networks
I want jut the results how I am going to get rid of that . Thanks
==========================
#!/usr/bin/perl
#
# Zygit Co-Branding
# Free Style
# Copyright (c) 2001 Zygit Networks
#
#
use LWP::Simple;
use LWP::UserAgent;
&cgi_header;
&cgi_receive;
# The location of your header and footer (full path not the address)
$header = "/home/www/header.html";
$footer = "/home/www/footer.html";
# If you rename the script, be sure to update this line. Use the
# URL address for this (http://www.you.ext/cgi-bin/search/metasearch.cgi)
$script_url = "metasearch.cgi";
# DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU ARE DOING!
#-------------------------
$startpage = $FORM{startpage};
$search = $FORM{search};
$skip = $FORM{skip};
if ($startpage eq "") { $startpage = 1 ; }
open (HEADER, "$header");
while (<HEADER>) { print; }
print <<EOF;
<center>
<form action="$script_url"><inpu
<br><a name=top>
</center>
EOF
if ($search eq "") {
exit(0);
} else {
$url = "http://www.zygit.com/cgi-bin/search/metasearch.pl?etype=web&search=$search&logfile=searches&startpage=$startpage";
}
my $ua = new LWP::UserAgent;
my $res = $ua->request(HTTP::Request->new(GET => $url));
my $content = $res->content;
@page = split(/\n/,$content);
for (@page){
$_ =~ s/#99CCCC/$header_color/g;
$_ =~ s/metasearch.pl/$script_ur
$_ =~ s/name="query"/name=search
if ($_ =~ /<!--pull -->/) { $print = "on"; }
if ($_ =~ /<!--stop -->/) { $print = "off"; }
if ($print eq "on") { print "$_\n"; }
}
print <<EOF;
<center>
<form action="$script_url"><inpu
<br><a name=top>
</center>
EOF
sub parse_form {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9]
$FORM{$name} = $value;
}
}
open (FOOTER, "$footer");
while (<FOOTER>) { print; }
# DO NOT TOUCH THIS!
sub cgi_header {
print "Content-type: text/html\n";
print "\n" unless ($FORM{'next-url'});
}
sub cgi_receive {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $incoming, $ENV{'CONTENT_LENGTH'});
}
else {
$incoming = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $incoming);
foreach (@pairs) {
($name, $value) = split(/=/, $_);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([A-F0-9][A-F0-9])/pack
$value =~ s/%([A-F0-9][A-F0-9])/pack
#### Strip out semicolons unless for special character
$value =~ s/;/$$/g;
$value =~ s/&(\S{1,6})$$/&\1;/g;
$value =~ s/$$/ /g;
$value =~ s/\|/ /g;
$value =~ s/^!/ /g; ## Allow exclamation points in sentences
#### Skip blank text entry fields
next if ($value eq "");
#### Check for "assign-dynamic" field names
#### Mainly for on-the-fly input names, especially checkboxes
if ($name =~ /^assign-dynamic/) {
$name = $value;
$value = "on";
}
#### Allow for multiple values of a single name
$FORM{$name} .= ", " if ($FORM{$name});
$FORM{$name} .= $value;
}
}
==========================
you can see the example at
http://www.wcws.net/metasearch.cgi?search=saasoh
I want something like that . .
could you please help me but the thing is I dont want anything like Powered by: Zygit Networks
I want jut the results how I am going to get rid of that . Thanks
1 #!/usr/bin/perl -w
2 use strict;
3 use CGI qw/:standard/;
4 $|++;
5 use WWW::Search;
6 my $Search = new WWW::Search('Google');
7 my $Query = WWW::Search::escape_query( param('que ry'));
8 $Search->native_query($Que ry);
9 print header,start_html("Google Results"),h1("Google Results:");
10 while (my $Result = $Search->next_result()) {
11 print "<a href='",$Result->url,"'>", $Result->u rl, "<br>\n";
12 }
13 print end_html;
2 use strict;
3 use CGI qw/:standard/;
4 $|++;
5 use WWW::Search;
6 my $Search = new WWW::Search('Google');
7 my $Query = WWW::Search::escape_query(
8 $Search->native_query($Que
9 print header,start_html("Google Results"),h1("Google Results:");
10 while (my $Result = $Search->next_result()) {
11 print "<a href='",$Result->url,"'>",
12 }
13 print end_html;
ASKER
i dont think there is a difference after you post that above script, same thing is happening..
i cant see the next page link nor the thing like
1- COMPANY NAME OF SEARCH
i cant see the next page link nor the thing like
1- COMPANY NAME OF SEARCH
<!-- Google -->
<form name=srchform action="http://www.google.com/search" method="GET">
<a href="http://www.google.com/">Google</a>
<input type=text size="20" name=q>
<input type=hidden name=num value="100">
<input type=submit name="action" value="Google">
</form>