Gossamer Forum
Home : Products : Links 2.0 : Customization :

Widgetz - Your Altavista.cgi Script.. I need Assistant.

Quote Reply
Widgetz - Your Altavista.cgi Script.. I need Assistant.
Hello widgetz,

How can this be done? please explain in details..

Quote:
posted October 23, 1999 10:36 PM PST
--------------------------------------------------------------------------------
sorta like this..
http://www.pdamania.com/search.cgi?query=test&search=Altavista

that is links sql.. but still.. i just slabbed altavista.cgi into search.cgi..

it's really easy

jerry

It s Amazing!... Please include step by step modification if neccessary.

Thank you for your valuable time and effort.

Take care!

------------------

WebKing
WebKing@trisoft.net
WebKing@viet-usa.com
http://www.trisoft.net
http://www.viet-usa.com
My ICQ # 25356171

Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Here are some suggestions:

1) Add the following codes to the top of your search.cgi file:

Code:
if ($in{'type'} eq ="local") {
&searchlocal;
}
if ($in('type'} eq="web") {
&altavista;
}

2) Put the following above your main search routine:

sub searchlocal {

Then at the end before the sub query, add a closing right bracket }.

3) Copy all the altavista search codes to the bottom of your search.cgi file.

4) Put the following before the altavista search codes:

sub altavista {

5) Then at the end of the altavista codes, put a closing right bracket, }.

6) In your search form, add the following radio buttons:

Code:
<input type="radio" name="type" value="local">
<input type="radio" name="type" value="web">

Logically, these codes should work.

Good luck!

Regards,


------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Hello! and Thanks very very very much! BUT.
Quote:
2) Put the following above your main search routine:

sub searchlocal {

Then at the end before the sub query, add a closing right bracket }.

3) Copy all the altavista search codes to the bottom of your search.cgi file.

4) Put the following before the altavista search codes:

sub altavista {

5) Then at the end of the altavista codes, put a closing right bracket, }.

6) In your search form, add the following radio buttons:


code:
--------------------------------------------------------------------------------

<input type="radio" name="type" value="local"><input type="radio" name="type" value="web">

--------------------------------------------------------------------------------

Logically, these codes should work.

I dont understand here. According to my understanding. I placed your #1 instruction on the top of my Seach.cgi which is below a line called #!usr/bin/perl OK.

And there are many functions in that Search.cgi which are sub main, sub search, and sub build_linked_title {. I dont know where to place your #2 instructions.

Where should I placed this? in the sub main? or somewhere else and treat it as a new function? and what you mean by put this code before sub altavista codes? just this plan text of INPUT and that s it?... Sorry for being stupid but I m confused. Thanks for your assistance!

Quote:
<input type="radio" name="type" value="local"><input type="radio" name="type" value="web">



------------------

WebKing
WebKing@trisoft.net
WebKing@viet-usa.com
http://www.trisoft.net
http://www.viet-usa.com
My ICQ # 25356171

Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I think i got it. Shouldn't I copy the #!usr/bin/perl also? or elimiate it? thanks
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Okay...here is a revised instruction list...I cannot gaurantee this will work (nor do I have any more time today to work on this with you...about to go off-line):

1) Add the following codes BEFORE sub main:

Code:
if ($in{'type'} eq ="local") {
&main;
}
if ($in('type'} eq="web") {
&altavista;
}

Forget step 2.

3) For the altavista SUB_ROUTINE, it should look like the following:

Code:
sub altavista {
#----------------------------------
# Altavista web search

use strict;
use CGI;
use LWP::Simple;

my $in = new CGI;

REST OF CODES
}

You place the INPUT fields (radio buttons) in your HTML search form, like in your search.html template file.

Hope this makes better sense and helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Your Perl Path (#!usr/bin/perl) only needs be placed ONCE in your file on the FIRST line of the file (for UNIX Servers)...basic cgi/perl programming tip.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
i only added 2 things to search.cgi

Code:
($in->param('search') eq "Altavista") and &altavista;

of course that is code for links sql.. so for links 2 it would be

Code:
($in{'search'} eq "Altavista") and &altavista;

and then the subroutine altavista is just:

Code:
sub altavista {
my $in = shift;
my $url = "http://www.altavista.com/cgi-bin/query?q=$query&text=yes&stq=$page";
use LWP::Simple;
my $results = get ($url);
$query = &urlencode($in->param('query'));
$page = (($in->param('nh')-1) * 10) || 0;

$results or &site_html_search_failure ({ error => "No Results Available.", %in }) and return;

# If we see this, then we couldn't get a match.
my $none = quotemeta ("AltaVista found no document matching your query.");

if ($results =~ m/$none/) {
&site_html_search_failure ({ error => "No Matching Links", %in }) and return;
}
else {
if ($results =~ /([^>\s]+) pages found./) { $link_hits = $1; }
else { &site_html_search_failure ({ error => "Can't Parse Results", %in }) and return; }

my $FONT = 'font face="verdana, arial" size="2"';
my $FONT_SMALL = 'font face="verdana, arial" size="1"';
if ($link_hits) {
while ($results =~ m#<dl><dt>\n<b>(\d+)\.\s*</b>\n<a href="([^"]+)">\n<b>([^<]+)</b></a></dt>\n<dd>([^<]*)</dd>\n<br><b>URL:</b> <font color="\#808080">([^<]+)</font>\n<br><font color="\#808080">\n([^<]+\n[^<]+)</font>#sog) {
($count, $url, $title, $description, $url2, $last) = ($1, $2, $3, $4, $5, $6);
$url2 =~ s,/$,,;
$last =~ s,\n,,;
$last =~ s,\s\s+, ,;
$link_results .= qq~<p>\n<$FONT_SMALL><b>$count.</b></font> <$FONT><a href="$url">$title</a><br>\n$description</font><br>\n<$FONT_SMALL><b>URL:</b> <font color="#808080">$url2</font></font><br>\n<$FONT_SMALL color="#808080">$last</font>\n</p>\n~;
}
}
}

$next = &next_hits($page, $link_hits, 10);
&site_html_search_results;
exit;
}

may need to be translated more for Links 2..

it also needs the original NEXT_HITS from altavista.cgi

jerry
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I followed your instructions widgetz and I get : fatal error: Can't call method "param" on an undefined value at /home/lod/cgi-bin/links/search.cgi line 307, chunk 66.

What does that mean?

http://www.linkondemand.com/...cgi?search=Altavista

Thanks,

------------------
- Jonathan Gamble

www.linkondemand.com/

[This message has been edited by jdgamble (edited November 29, 1999).]
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Has anyone succeded in doing this widgetz way?

------------------
- Jonathan Gamble

http://www.linkondemand.com/



Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I found the problem:

$page = (($in->param('nh')-1) * 10) &#0124; &#0124; 0;

what do I change this to in order to get rid of the param?

If I do:

$page = (($in('nh')-1) * 10) &#0124; &#0124; 0;

It screws up the whole file...



------------------
- Jonathan Gamble

http://www.linkondemand.com/



Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Change ist like this (except for language):

my $query = $in->param('query');
my $query_q = &urlencode($query);
my $page = ($in->param('nh') * 10) &#0124; &#0124; 0;
my $pageXX = $page - 10;
my $url = "http://www.altavista.com/cgi-bin/query?q=$query_q&text=yes&stq=$pageXX&kl=de";
my $results = get ($url);

JH
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I can not get this to work and it is getting very frustrating could someone help me??
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I really need help on this...

I do like you say:

sub altavista {
# --------------------------------------------------------
# Search Altavista

use LWP::Simple;
my $query = $in->param('query');
my $query_q = &urlencode($query);
my $page = ($in->param('nh') * 10) | | 0;
my $pageXX = $page - 10;
my $url = "http://www.altavista.com/cgi-bin/query?q=$query_q&text=yes&stq=$pageXX&kl=de";
my $results = get ($url);
$results or &site_html_search_failure ({ error => "No Results Available.", %in }) and return;
# If we see this, then we couldn't get a match.
my $none = quotemeta ("AltaVista found no document matching your query.");
if ($results =~ m/$none/) {
&site_html_search_failure ({ error => "No Matching Links", %in }) and return;
}
else {
if ($results =~ /([^>\s]+) pages found./) { $link_hits = $1; }
else { &site_html_search_failure ({ error => "Can't Parse Results", %in }) and return; }
my $FONT = 'font face="verdana, arial" size="2"';
my $FONT_SMALL = 'font face="verdana, arial" size="1"';
if ($link_hits) {
while ($results =~ m#<dl><dt>\n<b>(\d+)\.\s*</b>\n<a href="([^"]+)">\n<b>([^<]+)</b></a></dt>\n<dd>([^<]*)</dd>\n<br><b>URL:</b> <font color="\#808080">([^<]+)</font>\n<br><font color="\#808080">\n([^<]+\n[^<]+)</font>#sog) {
($count, $url, $title, $description, $url2, $last) = ($1, $2, $3, $4, $5, $6);
$url2 =~ s,/$,,;
$last =~ s,\n,,;
$last =~ s,\s\s+, ,;
$link_results .= qq~<p>\n<$FONT_SMALL><b>$count.</b></font> <$FONT><a href="$url">$title</a><br>\n$description</font><br>\n<$FONT_SMALL><b>URL:</b> <font color="#808080">$url2</font></font><br>\n<$FONT_SMALL color="#808080">$last</font>\n</p>\n~;
}
}
}
$next = &next_hits($page, $link_hits, 10);
&site_html_search_results;
exit;
}

And it still doesn't work... what am I doing wrong...?

------------------
- Jonathan Gamble

http://www.linkondemand.com/



Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
I got this to work, but i can't get the toolbar to

------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Nevermind, it works fine with my searh.cgi now.

------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
$in->param('????')

is equilvalent to Links 2.0's $in{'????'}

just to make it easier for you guys

jerry
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
That was all i did, and i also change my $in = shift; to %in = &parse_form;. And it works fine, except for when i search for www and when i search for a word that Altavista ignores, like and by itself

------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
if you got rid of

my $in = shift;

it would still work..

%in is already equal to the parsed form above.. that is why

$in{'search'} eq "Altavista" and &altavista;

works..

jerry
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Hi,

I've uploaded the altavista.cgi script and I'm just trying to do a query with the script and I can't seem to call it. I get a "document contains no data" as if it were a blank document! What am I'm missing here?? I'm not trying to place it in my search.cgi, I would just like to redirect a 'no search results keyword' to that script. I am using the script found in the the resource center under 'other scripts'. Any ideas? Thanks.

Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
you don't have LWP..

jerry
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Oh really? I just tried to install your review mod and when I went to run the install.cgi the same thing happened 'document contains no data'! Does the install use LWP also? I thought Links used LWP? I have that installed fine? What can I do if this is the case?

Thank You
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
The only script in LINKS that uses LWP is the nph-verify.cgi. However, if you do not LWP installed, this script will use HEADER method for verifying links.

Widgetz is correct...You do not have LWP installed.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
are you using a free host?

if not.. just tell your host to install the libwwwperl package..

or something like that..

hypermart has LWP.. virtualave doesn't.. spaceports (or something) doesn't..

jerry
Quote Reply
Re: Widgetz - Your Altavista.cgi Script.. I need Assistant. In reply to
Thanks guys, I'll have my host look into it!