Gossamer Forum
Home : Products : Links 2.0 : Customization :

A good question about links.

Quote Reply
A good question about links.
Hello the question I have is about links and META searching. What I want to do is when someone runs a search on my site and my site doesn't have any results that links will automatically Meta search another search engine. If you take Yahoo as an example if they do not have anything in there directory they automatically search Inktomi. I have a CGI script to META search AOL. I want to know how I can combine the two. I hope someone can help. Thanks
Quote Reply
Re: A good question about links. In reply to
My mods site, this should do it
http://lookhard.hypermart.net/...ds/inkyah-redir.html
Quote Reply
Re: A good question about links. In reply to
bmxer..

i suggest.. instead of..

Code:
$redir =~ s/\ /+/g;

you use..

Code:
$redir =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;

more compatibility... if you have no clue what i'm talking about.. then an example is.. what if you search for..

santa & mrs. clause

what your code does..

santa+&mrs.+clause

it will only search for santa...

this is what the code i gave you returns..

santa%20%26%20mrs.%20clause

%20 is a space.. (all search engines recognize it that way..)

%26 being &..

and yea.. now it will search for the whole string.. there are many other things that will screw up if you did it by changing spaces to a + sign..

jerry
Quote Reply
Re: A good question about links. In reply to
That's not much help Bmxer, but thanks anyway. What I mean is I want the results from the other search engine to show up on my pages. Like I said I have a way to META search AOL and return the results on my page, but I just need away to get links to run the search only if my search returns no results. Thanks
Quote Reply
Re: A good question about links. In reply to
it's a matter of an if/else and then simply combining the scripts into each other..

if you post your codes i can help.. otherwise if you tried to email me.. you'll only be adding your email to about 3 months worth of email i still have to get to..

jerry
Quote Reply
Re: A good question about links. In reply to
Here is the code for META searching Widgetz.

#!/usr/bin/perl
##############READ INPUT##############
read(STDIN, $inbuffer, $ENV{'CONTENT_LENGTH'});
$qsbuffer = $ENV{'QUERY_STRING'};
foreach $buffer ($inbuffer,$qsbuffer) {
@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;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/~!/ ~!/g;
$value =~ s/<([^>]|\n)*>//g;
$FORM{$name} = $value;
}
}
######################################

###############LOGICS#################
if ($ENV{'QUERY_STRING'} =~ /results/) { &results; }
else { &main; }
######################################

###############MAIN SUB#################
sub main {
print "Content-type: text/html\n\n";
print <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>LiquidEffect.com</title>
</head>
<body>
<table border=0 width="100%" cellspacing=0 cellpadding=0>
<tr><td valign=middle width="1%">
<a href="http://www.liquideffect.com"><img border="0" src="http://www.liquideffect.com/images/liquid_small.gif" width="210" height="40" alt="LiquidEffect.com">
</td>
<td align=right valign=top><font size="2" face="Arial"><a href="http://www.liquideffect.com/main/">Help</a> - </font>
<a href="http://mymail.liquideffect.com/"><font face="Arial" size="2">Check Email</font></a>
<hr size=1 noshade></td></tr></table>

<br>
<br>
<center><form action=metasearchlite.cgi?results method=post></center>
<br>
<center><table BORDER CELLSPACING=0 CELLPADDING=4 BGCOLOR="#CCCCCC" width="60%">
<tr>
<td>
<center><input type=text name=keywords size=25 value="$FORM{'keywords'}"> <input type=submit value=" Search "></center>
</td>
</tr>
</table></center>

<center><table BORDER=1 CELLSPACING=3 CELLPADDING=0 width="60%" BGCOLOR="#FFFFFF">
<tr>
<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Arts+and+Entertainment">Arts
and Entertainment</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Autos">Autos</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Business+and+Economics">Business
and Economics</a></font></center>
</td>
</tr>

<tr>
<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Computers">Computers</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Games">Games</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Health">Health</a></font></center>
</td>
</tr>

<tr>
<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Home">Home</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=News">News</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Recreation+and+Travel">Recreation
and Travel</a></font></center>
</td>
</tr>

<tr>
<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Reference">Reference</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Regional">Regional</a></font></center>
</td>

<td>
<center><font><a href="metasearchlite.cgi?results&keywords=Retail">Retail</a></font></center>
</td>
</tr>

<tr>
<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Science+and+Technology">Science
and Technology</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Society+and+Culture">Society
and Culture</a></font></center>
</td>

<td>
<center><font size=-1><a href="metasearchlite.cgi?results&keywords=Sports">Sports</a></font></center>
</td>
</tr>
</table></center>
<br>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td colspan="1" width="100%">
<table border=0 cellspacing=0 width=100%><tr>
<td><center><font face="arial" size="2"><b><a href="http://www.liquideffect.com/copyright.html">Copyright &#0169;</a> 1999-2000 LiquidEffect.com All Rights Reserved. <a href="http://www.liquideffect.com/policy.html">Privacy Policy</a></b></font></center></td></tr>
<td bgcolor="#FF0000"><table border=0 cellspacing=0 cellpadding=0><tr><td height=2></td></tr></table></td></tr></table>
<center><font face="Arial" size="1">
<a href="http://www.liquideffect.com/aboutus.html">About Us!</a> - <a href="http://www.liquideffect.com/advertise.html">Advertise On LiquidEffect.com</a> - <a href="http://www.liquideffect.com/contributors.html">Contributors</a> -
<a class="menulink" href="<%db_cgi_url%>/jump.cgi?ID=random">Random Link</a> - <a href="http://www.rsac.org">RSAC Rated</a> -
<a class="menulink" href="<%db_cgi_url%>/add.cgi">Suggest a Site</a> - <a href=http://www.recommend-it.com/p.e?475699 onClick="window.open('http://www.recommend-it.com/p.e?475699', 'RIC','width=370,height=410,resizable=yes');return false;">Tell A Friend</a>
</font></center></td>
</tr>
</table>
</body>
</html>
EOF
exit;
}
######################################


###############SEARCH RESULTS#################
sub results {
$| = 1;
use LWP::Simple;

#Define some variables
$keys = $FORM{'keywords'};

#Format Variables
$keys2 = $keys;
$keys2 =~ tr/+/ /;
$keys =~ tr/ /+/;

#HTML Code
my $title = shift(@_);
print "Content-type: text/html\n\n";
print "<html><head><title>LiquidEffect.com: Search Results</title>\n";
unless ($FORM{'first'}) {
$first="1";
$last="10";
}
else {
$first=$FORM{'first'};
$last=$FORM{'last'};
}
print <<EOF;
<style><!-- a:{color:#0000A0} a:vlink{color:#0000A0} a:hover{color:#FF0000} --></style>
</head>
<body vlink="#0000FF">
<FORM METHOD="POST" ACTION="metasearchlite.cgi?results">
<table border=0 width="100%" cellspacing=0 cellpadding=0>
<tr><td valign=middle width="1%">
<a href="http://www.liquideffect.com"><img border="0" src="http://www.liquideffect.com/images/liquid_small.gif" width="210" height="40" alt="LiquidEffect.com">
</td>
<td align=right valign=top><font size="2" face="Arial"><a href="http://www.liquideffect.com/main/">Help</a> - </font>
<a href="http://mymail.liquideffect.com/"><font face="Arial" size="2">Check Email</font></a>
<hr size=1 noshade></td></tr></table>
<table width="100%" bgcolor="#FF0000"><tr><td><table width="100%" bgcolor="#D3D3D3"><tr><td>
<font face="arial"><b>Search Results</b></font>
<font face="arial" size="-1">Found the first <b>$first</b> thru <b>$last</b> for <b>$keys2</b></font>
</td></tr></table>
</td>
</tr>
</table>
EOF


print <<EOF;
<br><center><SCRIPT SRC="http://www.liquideffect.com/banner.js"></SCRIPT></center><br>

EOF


$name = "AolNetFind";
$url = "http://www.aolnetfind.com";
$search = "http://search.aol.com/dirsearch.adp?query=$keys&first=$first&last=$last&next=item&cat=0";
$split = "\n";
$mark1 = "<FONT COLOR=#990000 STYLE=\"font-weight:bold; font-size:12px\">";
$mark2 = "next</A></FONT>";

@searches = split(/\^/,$search);

print "<BR>\n";
$found = 0;

$rank = 0;

$page = get($search);
$page=~ s/\d\d\d%//g;
@searchlines = split(/$split/, $page);

foreach $line(@searchlines) {

if ($line =~ /$mark1/ && $found == 0 && $rank == 0) {

if ($line =~ /$mark2/ && $found == 0 && $rank == 0) {
$rank = "2";
} else {
$line =~ s/The following results are from the World Wide Web and may contain objectionable material that LiquidEffect.com does not endorse./ /;

print "$line </I>";
}

}

if ($rank == "2") {
$found = -1;
}

if ($found) { last }

}
if ($found) {
$num=$num+1;
print "$num\n";
}

else {
print "\n";
}

#declare new first and last variables
$first=$first+10;
$last=$last+10;

print <<EOF;
<br><br><br><center><SCRIPT SRC="http://www.liquideffect.com/banner.js"></SCRIPT></center><br><br>
<center><table bgcolor="#000000" border=0 cellpadding=0 cellspacing=0><tr><td><table border=0 cellpadding=5 cellspacing=1><tr bgcolor="ccccaa"><td><b>
EOF

if ($page=~ /next<\/FONT><\/A>/) {
print <<EOF;
<a href="metasearchlite.cgi?results&keywords=$keys&first=$first&last=$last">Next 10 Matches</a>
EOF
}

print <<EOF;
</b></td></tr></table></td></tr></table></center>
<table border=0 cellspacing=0 width=100%><tr><td bgcolor="#D3D3D3"><table border=0 cellspacing=0 cellpadding=0><tr><td height=2></td></tr></table></td></tr></table>
<br>
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR="#FFFFFF" width="100%">
<tr>
<td>
<center><input type=text name=keywords size=25 value="$FORM{'keywords'}"> <input type=submit value=" Search "></form></center>
</td>
</tr>
</table></center>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
<tr>
<td colspan="1" width="100%">
<table border=0 cellspacing=0 width=100%><tr>
<td><center><font face="arial" size="2"><b><a href="http://www.liquideffect.com/copyright.html">Copyright &#0169;</a> 1999-2000 LiquidEffect.com All Rights Reserved. <a href="http://www.liquideffect.com/policy.html">Privacy Policy</a></b></font></center></td></tr>
<td bgcolor="#FF0000"><table border=0 cellspacing=0 cellpadding=0><tr><td height=2></td></tr></table></td></tr></table>
<center><font face="Arial" size="1">
<a href="http://www.liquideffect.com/aboutus.html">About Us!</a> - <a href="http://www.liquideffect.com/advertise.html">Advertise On LiquidEffect.com</a> - <a href="http://www.liquideffect.com/contributors.html">Contributors</a> -
<a class="menulink" href="<%db_cgi_url%>/jump.cgi?ID=random">Random Link</a> - <a href="http://www.rsac.org">RSAC Rated</a> -
<a class="menulink" href="<%db_cgi_url%>/add.cgi">Suggest a Site</a> - <a href=http://www.recommend-it.com/p.e?475699 onClick="window.open('http://www.recommend-it.com/p.e?475699', 'RIC','width=370,height=410,resizable=yes');return false;">Tell A Friend</a>
</font></center>
</td>
</tr>
</table>
</body>
</html>
EOF
exit;
}
######################################



Quote Reply
Re: A good question about links. In reply to
Its exactly what you asked in the first post. You didn't specify you wanted the one script to search another database or whatever.