Gossamer Forum
Home : Products : Links 2.0 : Customization :

altavista search - new mod

(Page 2 of 3)
> > > >
Quote Reply
Re: altavista search - new mod In reply to
I have been trying for days to get this to work - 500 error each time.

As others have done it successfully, i can only concur that the formatting is at fault here, although I’ve tried cut & paste with 4 different browsers all to no avail!

You can see my search.cgi here:
http://www.comtensolutions.com/test/search.txt

any ideas?

The Marshal
--------------
Quote Reply
Re: altavista search - new mod In reply to
Replace your sub altavista with this:

Code:
sub altavista {
# --------------------------------------------------------
# Search Altavista
my %in = &parse_form;
use LWP::Simple;
my $query = $in{'query'};
my $query_q = &urlencode($query);
my $page = ($in{'nh'} * 10) | | 0;
my $pageXX = $page - 10;
my $url = "http://www.altavista.com/cgi-bin/query?q=$query_q&text=yes&stq=$pageXX";
my $results = get ($url);
$results or &site_html_search_failure ({ error => "No Results Available.", %in }) and exit;
# 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 exit;
}
else {
if ($results =~ /([^>\s]+) pages found./) { $link_hits = $1; }
else { &site_html_search_failure ({ error => "Can't Parse Results", %in }) and exit;
}
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">http://$url2</font></font>\n~;
}
}
}
$next = &next_hits($page, $link_hits, 10);
if ($in{'search'} eq "both") {
$link_results2 = $link_results;
$link_hits2 = $link_hits;
$next2 = $next;
return;
}
&site_html_search_results;
exit;
}

And remember to remove the space between | |.

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

www.magicdirectory.com/






[This message has been edited by jdgamble (edited April 12, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
Hi,

Sounds like a great mod. If I understand it right, the mod will give you altavista results in your site ? besides links ?

Could this complete and revised mod be posted "together" in one post ? Please Smile

I read everything and couldn't help to be confused, thank you in advance,

Pat//
Quote Reply
Re: altavista search - new mod In reply to
Well the changes I made worked, to a point.
As you have already stated jdgamble that is what is exactly happening now.

If the search returns no matches on our site using both then it
returns a no matches found.

I understand your comment about adding the tags to the search_error.html
but I don't see how this will work properly as when some one finds a match
using just "the web" they would be taken to the search error page
which is set-up to say something like No sites matched your search.
but then it would list all the matches for just the web, if you
follow that.

It wouldn't show matches if some one didn't get a match by using
"categories" because of the tag <%if link_hits2%> or the tag
<%if link_results2%> is there a way to set it up using "if else"

This way if it went to the error page it would first look to
see if "both" was used and display the matches, or "else" display
the statement no matches found. Am I right about this and if so
how can this be done. If I am not please correct me. Any ideas??
Maybe Eliot can help with this.

jdgamble, don't get me wrong this is by far one of the best mods I
have seen as it adds lots of content to a site and makes any site
with your mod that much more attractive to users, there has to be
a way for this to work the way you planned it would, Also there
seems to be a problem in the way you list your code as I have
stated before and now the Marshal, I use IE and netscape and I can
cut and paste other peoples codes just fine
yet when I cut and paste
yours I get errors, is there a way you can copy your codes to a
plain text file and post it on a public page at your site for others.

Regards,
Redneck

------------------
On-line Canada.com
http://www.on-linecanada.com
Internet Directory & Website Resource Centre
Quote Reply
Re: altavista search - new mod In reply to
sorry the above should be using the "both" selection and not
"the web" selection

ie.
I understand your comment about adding the tags to the search_error.html
but I don't see how this will work properly as when some one does
not find a match on the sites end using "both" they would
be taken to the search error page which is set-up to say something
like No sites matched your search but then it would list all the
matches for just the web, if you follow that.


------------------
On-line Canada.com
http://www.on-linecanada.com
Internet Directory & Website Resource Centre
Quote Reply
Re: altavista search - new mod In reply to
Patricio,

Look at the examples jgamble provided.

RedNeck,

I still don't understand why it is not working for you.

BTW: I have my search templates structured very differently. But it still works for me.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: altavista search - new mod In reply to
There still is a few bugs in it that I have found. I think this is what you are talking about. For example, if you search for something that can't be found in your database, but altavista can find it, then it goes biserk and has problems. I will get this straightened out, and when I do, I will post it here.

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

http://www.magicdirectory.com/




Quote Reply
Re: altavista search - new mod In reply to
That problem is solved if you go with your original Modification, jdgamble. If you have two subs..."both" and "altavista"...the second will be referenced when there are no search terms found. This is what I have and it works just fine.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: altavista search - new mod In reply to
I was talking about that if you search 'both' and you don't have any results in your links database, rather there is altavista results or not, you don't get any results and you get site_html_failure.

But your right and thats really not a big deal.

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

http://www.magicdirectory.com/

[This message has been edited by jdgamble (edited March 27, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
I have switched to the other mod till you get this sorted out
jdgamble, I can't wait till it works.

Eliot:
Yep that is exactly what is happening, like jdgamble said if you
search using say "the directory" (local) works fine as well
if you search using "altavista" it works fine.

But if you search using "both" and if you don't have any local
matches it won't return altavista matches it throws up the search
error page.

Any Ideas Eliot.

Regards,
Redneck



------------------
On-line Canada.com
http://www.on-linecanada.com
Internet Directory & Website Resource Centre
Quote Reply
Re: altavista search - new mod In reply to
Yea...Redneck....

Change the following codes:

Code:
&site_html_search_failure ("no matching records") and return;

with the following:

Code:
&altavista () and return;

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: altavista search - new mod In reply to
The only problem I can see with that is that when you run the altavista sub routine... again, it will keep returning because of the "search=both".

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

http://www.magicdirectory.com/




Quote Reply
Re: altavista search - new mod In reply to
Not for me. Works just fine. And to prove my point...go here:

http://vlib.anthrotech.com/...l=or&format=full

You will see that if there is absolutely NO matching words between my directory or altavista...the Search Failed page comes up.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 30, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
Eliot:

I just installed the mod again with the info you gave, same problem.

I've put my search.cgi script on the site if you want to have a look
http://www.on-linecanada.com/search.html

try searching for "marcus" you'll see that my site returns no matches
but neither does altavista, if you go to altavista it does return
matches for "marcus"

Regards,
Redneck


------------------
On-line Canada.com
http://www.on-linecanada.com
Internet Directory & Website Resource Centre
Quote Reply
Re: altavista search - new mod In reply to
 
Code:
# Return unless we have results.
((keys %link_results > 0) or ($#category_results >= 0)) or
&site_html_search_failure ("no matching records") and return;

See the line that I told you change...

Code:
&site_html_search_failure ("no matching records") and return;

This needs to be changed to:

Code:
&altavista () and return;

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: altavista search - new mod In reply to
--------------------------------------------------------------------------------
Quote:
Not for me. Works just fine. And to prove my point...go here:
http://vlib.anthrotech.com/bin/search.cgi?query=asdfasrwer&mode=both&bool=or&format=full

You will see that if there is absolutely NO matching words between my directory or altavista...the Search Failed page comes up.

Maybe I made some confusion. Sorry. I was trying to agree with you.


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

www.magicdirectory.com/
Quote Reply
Re: altavista search - new mod In reply to
 
Quote:
The only problem I can see with that is that when you run the altavista sub routine... again, it will keep returning because of the "search=both".

This statement does not seem to be agreeing, but contesting (disagreeing) with my statements.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: altavista search - new mod In reply to
Sorry, I didn't mean returning, I meant the site_html_search_failure page.

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

www.magicdirectory.com/
Quote Reply
Re: altavista search - new mod In reply to
What about the this page? If you put the codes as I suggested for RedNeck the Mod will work fine....but I think, again, our channels crossed.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: altavista search - new mod In reply to
I was talking about something different anyway. Oh well. It doesn't matter.

Smile



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

www.magicdirectory.com/
Quote Reply
Re: altavista search - new mod In reply to
What a great mod!

I keep getting two syntax errors at the bottom of the altavista routine though. The problems pop up on the 2nd and 7th lines of the code below:

Code:
$next = &next_hits($page, $link_hits, 10)
if ($in{'search'} eq "both") {
$link_results2 = $link_results;
$link_hits2 = $link_hits;
$next2 = $next;
return;
}

In both cases, my checker indicates the errors are near the curly brackets at the end of the lines. If I leave the code in, I can't get through to the search page. When I take it out, I am able to search, but only through my own database OR Altavista -- not both. (Setting my search form to "Both" gives me Altavista-only results.)

Any suggestions for troubleshooting? I've poured over the code several times and can't seem to see the problem.

Thanks!
Quote Reply
Re: altavista search - new mod In reply to
In regards to my previous post, changing...

Code:
$next = &next_hits($page, $link_hits, 10)

...to (note the semi-colon at the end)...

Code:
$next = &next_hits($page, $link_hits, 10);

...made all the difference in the world!

Thanks, Jonathan, for the great mod.
Quote Reply
Re: altavista search - new mod In reply to
is there a finished version of this mod in the resource section, I havent seen it..

Quote Reply
Re: altavista search - new mod In reply to
I don't believe so...jgamble, I believe, is still working on fixing some of the bugs.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: altavista search - new mod In reply to
It is finished. Look at the first two posts at the top of this message. The only bug in it is that if you select search=both, and you don't have any links in your database, then you will get the site_html_search_failure page and you won't get any altavista results. But this can be fixed easily by editing your sub routine for the search failure page. Example:

Code:
There are no links in my database so here are altavista's results:

<%link_results2%>

and by adding the

Code:
link_results2 = $link_results2;

in site_html_templates.


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

www.magicdirectory.com


> > > >