I have gotten several emails about this mod this week, but I was not the origional creator, however, I have fixed several bugs in it... if you see any more, drop me a line... you are going to have to customize this to fit your site b/c i don't have time to write instructions.....
In Reply To:
sub altavista {
# --------------------------------------------------------
# Search Altavista
my %in = &parse_form;
use LWP::Simple;
# Boolean Options
if ($in{'bool'} eq 'and') {$bool = '+AND';}
elsif ($in{'bool'} eq 'or') {$bool = '+OR';}
else {$bool = '';}
if (!$in{'query'}) { &site_html_search_failure ("Please enter one or more keywords.") and return; }
# Define Variables
my $page = ($in{'page'} * 10) || 0;
my $pageXX = $page - 10;
my $query = $in{'query'};
my $query_q = &urlencode($query);
my $url = "http://www.altavista.com/cgi-bin/query?q=$query_q$bool&text=yes&stq=$pageXX";
my $results = get ($url);
my $FONT = 'font face="verdana, arial" size="2"';
my $FONT_SMALL = 'font face="verdana, arial" size="1"';
$results or &site_html_search_failure ("There are no results available!") and return;
# If we see this, then we couldn't get a match.
if ($results =~ /AltaVista found no document matching your query./) {
&site_html_search_failure ("No matching AltaVista links!") and return;
}
else {
if ($results =~ /([^>\s]+) pages found./) { $link_hits2 = $1; }
else { &site_html_search_failure ("Can't parse AltaVista results!") and return; }
}
if ($link_hits2) {
while ($results =~ m#<b>#sog) {
$results =~ s/<b>//gie;
$results =~ s/<\/b>//gie;
}
while ($results =~ m#<EM>#sog) {
$results =~ s/<EM>//gie;
$results =~ s/<\/EM>//gie;
}
while ($results =~ m#<a href="([^"]+)">\n([^<]+)</a></dt>\n<dd>([^<]+)</dd>\n
<font color="\#808080">URL:([^\n]+)\n#sog) {
($url, $title, $description, $url2) = ($1, $2, $3, $4);
$url2 =~ s/\s//gie;
if ($in{'nosum'} eq '1') {
$link_results2 .= qq~<li><$FONT><a href="$url">$title</a></font>
</li>\n~;
}
else {
$link_results2 .= qq~<li><$FONT><a href="$url">$title</a>
\n$description</font>
\n<$FONT_SMALL><b>URL:</b> <font color="#808080">http://$url2</font></font>\n
<$FONT_SMALL><a href="http://www.magicdirectory.com/cgi-bin/translate.cgi?url=$url">translate it</a></font>
</li>~;
}
}
}
$span2 = &next_hits($page, $link_hits2, 10);
# Bold Search Terms
@search_terms = split (/\s/, $in{'query'});
if (($in{'bold'} == 0) or (!$in{'bold'})) {
foreach $term (@search_terms) {
$link_results2 =~ s,(<[^>]+>)|(\Q$term\E),defined($1) ? $1 : "<STRONG>$2</STRONG>",gie;
}
}
if ($in{'search'} eq "both") {
return;
}
&logsearch;
&site_html_search_results;
exit;
}
(I quoted it for easier use!)
- Jonathan
http://www.magicdirectory.com/
http://www.magicdirectory.com/cgi-bin/search.cgi?query=david blaine
http://www.magicdirectory.com/cgi-bin/search.cgi?query=david blaine&search=theweb
http://www.magicdirectory.com/cgi-bin/search.cgi?query=david blaine&search=both