Gossamer Forum
Home : Products : Links 2.0 : Customization :

Altavista mod

Quote Reply
Altavista mod
I searched the forums and i am trying to understand the changes you made to Altavista code but i cannot get the point.
So please, if anyone know , can post ALL the code here and where should be added? I am confused!


Quote Reply
Re: Altavista mod In reply to
why don't you show us what you have so far?

Happy coding,

--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com
Quote Reply
Re: Altavista mod In reply to
Thanks for replying,
I have tryied to add the code but i did nothing. I don't now if i have the right code.
All i want is a metacrawler to allow my visitors search the web in my site.
If you want to help me i can give you my username and password to ftp the code reather than writing here(as it may take time).
I haven't added any websites in my database yet(just 10sites) because i have just started, so you will be able to loggin and upload the code.
I can mail my password and username if you want.
Give me your email.
Thanks a lot!

Quote Reply
Re: Altavista mod In reply to
Hi junko,

I try to pull out the links but still blank, the page only show the spanning without result, that mean there was something i forgot to code the script:

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 exit; }

# Define Variables
my $page = ($in{'page'} * 10) || 0;
my $pageXX = $page - 10;
my $query = $in{'query'};
my $query_q = &urlencode($query);
my $url = "http://web.altavista.com/cgi-bin/query?q=$query_q";
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 exit;

# 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 exit;
}
else {
if ($results =~ /We found ([^>\s]+) results:/) { $link_hits2 = $1; }
else { &site_html_search_failure ("Can't parse AltaVista results!") and exit; }
# Remove Bolded text
while ($results =~ m#<b>#sog) {
$results =~ s/<b>//gie;
$results =~ s/<\/b>//gie;
}
while ($results =~ m#
#sog) {
$results =~ s/
//gie;
$results =~ s/
//gie;
}
while ($results =~ m#<span class=x>#sog) {
$results =~ s/<span class=x>//gie;
$results =~ s/<span class=x>//gie;
}
while ($results =~ m#<EM>#sog) {
$results =~ s/<EM>//gie;
$results =~ s/<\/EM>//gie;
}
$count = 0;
# Pull out the links
while ($results =~ m|
href="([^"]+)" onMouseOver="status='([^']+)'\; return true\;">([^<]+)</a> <span id="(\d+)" class=y></span>\n
\n([^<]+)|sog) {
$count+1;
($count, $title, $url, $description) = ($1, $2, $3, $4);
$url2 =~ s/\s//gie;
$url2 = qq|http://$url2|;
%tmp = ("Count", $count, "URL", $url, "Title", $title, "Description", $description, "URL2", $url2);
$link_results2 .= &site_html_altavista_link (%tmp) . "\n";
}
}
$next2 = &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; }
&site_html_search_results;
exit;
}

sub next_hits {
# --------------------------------------------------------
# Creates a next hits toolbar.
#
my ($page, $numhits, $maxhits) = @_;
my ($left, $right, $upper, $lower, $next_hit, $prev_hit, $i);
my $nh = int ($page / $maxhits) || 1;
my $output = '';
$numhits =~ s/,//g;
$numhits = int ($numhits);

$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&page=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;

# First, set how many pages we have on the left and the right.
$left = $nh;
$right = int($numhits/$maxhits) - $nh;
# Then work out what page number we can go above and below.
($left > 7) ? ($lower = $left - 7) : ($lower = 1);
($right > 7) ? ($upper = $nh + 7) : ($upper = int($numhits/$maxhits) + 1);
# Finally, adjust those page numbers if we are near an endpoint.
(7 - $nh >= 0) and ($upper = $upper + (8 - $nh));
($nh > ($numhits/$maxhits - 7)) and ($lower = $lower - ($nh - int($numhits/$maxhits - 7) - 1));

# Then let's go through the pages and build the HTML.
($nh > 1) and ($output .= qq~<a href="$ENV{'SCRIPT_NAME'}?$next_url&page=$prev_hit">[<<]</a> ~);
for ($i = 1; $i <= int($numhits/$maxhits) + 1; $i++) {
if ($i < $lower) { $output .= " ... "; $i = ($lower-1); next; }
if ($i > $upper) { $output .= " ... "; last; }
($i == $nh) ?
($output .= qq~$i ~) :
($output .= qq~<a href="$ENV{'SCRIPT_NAME'}?$next_url&page=$i">$i</a> ~);
(($i * $maxhits) >= $numhits) and print "Exiting3" and last; # Special case if we hit exact.
}
$output .= qq~<a href="$ENV{'SCRIPT_NAME'}?$next_url&page=$next_hit">[>>]</a> ~ unless ($nh == $i);
return $output;
}

Please help and thank you.


Quote Reply
Re: Altavista mod In reply to
Most likely Altavista has changed their query string YET again...this mod is highly volatile due to relying on a third party search engine...my advice:

DON"T use the ALTAVISTA MOD...

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: Altavista mod In reply to
Have anyone tried to get results from any other metacrawler???
If yes give me the url of the forum.

Quote Reply
Re: Altavista mod In reply to
In Reply To:
If yes give me the url of the forum.
A 'Please' would be nice Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Altavista mod In reply to
PLEASE give me the URL...pleaseeeeee...