Gossamer Forum
Home : Products : Links 2.0 : Customization :

altavista search - new mod

(Page 3 of 3)
> >
Quote Reply
Re: altavista search - new mod In reply to
 
Quote:
It is finished. Look at the first two posts at the top of this message...

Then...Have you submitted it to the Resource Center?

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 knew I was forgeting something...

I just submitted it unless someone beat me...

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

www.magicdirectory.com


Quote Reply
Re: altavista search - new mod In reply to
Actually, I think there's another bug in the code as written above. I'll try and explain it the best I can.

In my search_results template, I have three separate areas defined by conditional statements:

Code:
<%if category_results%>
...
<%endif%>

<%if link_results%>
...
<%endif%>

<%if link_results2%>
...
<%endif%>

Within each of those statements, I have my appropriate link results, link hits, and next hits toolbars. I ALSO have a text string that identifies the area (i.e. Category Matches, Site Matches, Web Page Matches -- like Yahoo).

Everything works great when I run a search in my own categories, or both the categories and the Web.

BUT... when I run a Web-only search, I get my AltaVista results back within the <%if link_results%> statement and NOT the <%if link_results2%> statement. Which means the text string that pops up says "Site Matches" rather than "Web Page Matches."

I noticed at that Magic Directory Jonathan linked to in his first post the problem doesn't occur. Anyone have an idea where the best place to look would be? The solution to all this is probably staring me right in the face, but code-crunching has me a little weary.

Thanks!

[This message has been edited by troyw (edited April 10, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
Well, its not my code that has the bug, its your code. Simple. In your case make the following changes.

Change:
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 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">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;
}

to...

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 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_hits2 = $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_hits2) {
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_results2 .= 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~;
}
}
}
$next2 = &next_hits($page, $link_hits2, 10);
if ($in{'search'} eq "both") {
return;
}
&site_html_search_results;
exit;
}

or something of the sort...



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

www.magicdirectory.com

[This message has been edited by jdgamble (edited April 10, 2000).]

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

Thanks, Jonathan, for the great mod and the suggested code change.
Quote Reply
Re: altavista search - new mod In reply to
I am having some problems with this mod.. if anyone wants to have a look at it its at
internetevim.virtualave.net/links2/pages/ try searching for anything all you get is 500 server error.

you can see my site_html_templates.cgi at internetevim.virtualave.net/links/site_html_templates.txt and the search.cgi at internetevim.virtualave.net/links/search.txt

really need some help, thanks.
Ugur
Quote Reply
Re: altavista search - new mod In reply to
Hey, Jonathan--

Excellent mod! I'm really excited about the prospects of using this. I just have two quick questions for you (or anyone else who's working with it):

1.) Why does the next hits toolbar return only the first 19 pages of AltaVista results (even if you have something like 7 million matches)?

2.) I applied the change you suggested to troyw up above, and now I'm getting some weirdness if I try to run a search on the Web or Both and I don't have anything typed into the Search field. My search error layout gets repeated twice on the same page, the top one saying "There was a problem with your search: HASH(0x102039b0)" and the bottom one saying what it should ("There was a problem with your search: Please enter one or more keywords.") This doesn't occur when I run a search in only my categories and leave the field blank (in which case I get just the "Please enter one or more keywords" statement). Any thoughts on where I might be triggering the dual error?

At any rate, great job! This is really cool!!

Thanks,

blane
Quote Reply
Re: altavista search - new mod In reply to
Hey blane,

I do not really understand your first problem. Did you trie to click on for example link 18 ? Then you automaticaly will see the next 20 on next hits toolbar.
If you have 2.000.000 links and want to see the toolbar display all (10 links per page) you will get 200.000 links on your page Smile little too much i think Wink

When your second error occurs - are you online ? I always get the same when im not online - how can the script search the web if you are not online Smile
Try it when you are in the internet.
cya,

nikolai
Quote Reply
Re: altavista search - new mod In reply to
DigitalFusion,

The problem I'm having with the next hits toolbar is the very same one that's apparent on those Magic Directory pages linked way up at the top of this topic. Click on page 19 of the AltaVista area and that's the end of the line...

As for the second issue involving the stacked error messages, yes I'm online. I have a direct connection. The problem just started occuring when I applied those code changes suggested by Jonathan a few posts up.

Thanks for the input! Always appreciated.

blane
Quote Reply
Re: altavista search - new mod In reply to
I think I fixed the 19 page think. In sub next_hits put # sign on this line:

Code:
# last if ($i > 19);

http://www.magicdirectory.com/...mp;bool=or&nh=19

Quote:
2.) I applied the change you suggested to troyw up above, and now I'm getting some weirdness if I try to run a search on the Web or Both and I don't have anything typed into the Search field. My search error layout gets repeated twice on the same page, the top one saying "There was a problem with your search: HASH(0x102039b0)" and the bottom one saying what it should ("There was a problem with your search: Please enter one or more keywords.") This doesn't occur when I run a search in only my categories and leave the field blank (in which case I get just the "Please enter one or more keywords" statement). Any thoughts on where I might be triggering the dual error?

The change was only meant for troyw's case. I suggest you copy the origional altavista from the top of this message and change the first three return; to exit;.


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

www.magicdirectory.com


Quote Reply
Re: altavista search - new mod In reply to
Jonathan:

I'm actually experiencing the same thing as blane in regards to dual error messages. (I never thought to run a search for nothing until he mentioned it...) It's something about that new code. I'll post if I can run the bug down.

Also, I noticed when I took a look at
http://www.magicdirectory.com/...mp;bool=or&nh=19
you have a cosmetic issue that I had when I first got everything up and running. At the very top there's an orphaned next hits toolbar for the Sites section just floating up there all by itself. I fixed this by making sure the if statement for the hits toolbar was INSIDE the link_results if statement.

Take care,

Troy
Quote Reply
Re: altavista search - new mod In reply to
Looks like Jonathan is editing his script since I am getting an Internal Server Error.

I tried looking at the examples provided to get a feel for what people are talking about, and I got the Internal Server Error.

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
Hey all,

I tracked down why I was getting those dual error messages. It had to do with some code I changed to fix an earlier problem.

I'd suggest to Blane that he fly through and double-check everything, especially the first couple lines of the "main" subroutine in search.cgi. That's where I had made a change that I forgot about. If all else fails, reapply Jonathan's code from scratch.

Take care,

Troy
Quote Reply
Re: altavista search - new mod In reply to
Yeah Eliot, I was working on a different mod for a different post. I usually make a new search file but I didn't have the time.

Quote:
troyw
I fixed this by making sure the if statement for the hits toolbar was INSIDE the link_results if statement.

Can you post the code here or the exact changes to make... I'm trying to do 10 different things right now and it would really help me out.

Also, as for the 19 thing, on the 19th page it replaces '>>' with '...' for some reason, any ideas?

Thanks,

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

www.magicdirectory.com


Quote Reply
Re: altavista search - new mod In reply to
Jonathan,

Here's the code for the link_results section of my search_results.html file. As I mentioned before, I just made sure the second <if next> statement was within the overall <if link_results> statement. You'll have to customize, of course, if you're within a table...

Code:
<%if link_results%>
Site Matches <b>(<%link_hits%> found)</b></p>
<%if next%>
<p>Pages: <%next%></p>
<%endif%>
<ul>
<%link_results%>
</ul>
<%if next%>
<p>Pages: <%next%></p><%endif%>
<%endif%>

I'll take a look at that "..." issue tonight.

[This message has been edited by troyw (edited April 11, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
Thanks, I thought you were talking about if statements in the actual cgi-file. I had my first next hits in the if statement, but my second next hits were not. It is fixed now.

Right now I'm looking into the 19th thing, it may not be a problem, but I need to see.

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

www.magicdirectory.com


Quote Reply
Re: altavista search - new mod In reply to
if you guys have sometime I would appreciate if you could also have a look at my problem..

thanks
ugur
Quote Reply
Re: altavista search - new mod In reply to
UGUR--

In the altavista subroutine in search.cgi, try changing...

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

...to this:

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

Note the semi-colon at the end of the line...

JONATHAN--

"19" is mentioned twice down there in the code. You commented out the first occurence, but I think it's that second one that's giving you the "..." Haven't had time to play with some fixes, but will tomorrow.

BTW, how did you handle returning a "Please enter one or more characters" error when searching "the web" or "both" with a blank search field? I'm getting a pesky Hash error. I get the correct error ONLY when I have it set to "categories."

Also, you might want to change the code up at the top of this page to address my above comment to Ugur.

Take care,

Troy

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

thanks for the reply, I have changed what you advised, but I beleive there is still one or more bracket or semi-colon problem at my search.cgi. cause when I try to search anything it just gives me 500 server stuff, doesnt bring any page at all.

here is my updated pages at.

thanks for your time

my main page
internetevim.virtualave.net/links2/pages/
template.pl
internetevim.virtualave.net/links/site_html_templates.txt
search.cgi
internetevim.virtualave.net/links/search.txt
Quote Reply
Re: altavista search - new mod In reply to
Ok.... here we go...

To fix the 19 thing again... in search.cgi:

Change the sub next hits thing to:
Code:
$output .= qq~<a href="$ENV{'SCRIPT_NAME'}?$next_url&nh=$next_hit">[>>]</a> ~ unless ($nh == $i);

For the error for no search terms, add the following line to sub altavista:

Code:
if (!$in{'query'}) { return ("Please enter one or more keywords."); }

Thanks for pointing that out to me...


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

www.magicdirectory.com


Quote Reply
Re: altavista search - new mod In reply to
Might I suggest that people create another Topic and link to this Topic...This Topic is getting hard to follow and it is 125KB large.

Just a suggestion.

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
Ugur

Sorry I didn't reply earlier, I missed your message.

I took a look at your search file, and let me say it is VERY unorganized and hard to find information. I copyied it and ran it on my server still having problems.

You entire next hits sub routine is in the middle of the sub search. And also some of the next hits search from the top is gone. I suggest you reinstall every mod that you did for search.cgi. If you tell me what mods you have on there (obviously the non-engish mod), I will do it for you.

PAGE2!!!
http://www.gossamer-threads.com/...um3/HTML/005757.html

------------------
- 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
i was wondering if this mod work with other search engine such as allmp3.com and 2look4.com or maybe yahoo.com

Thanx
Quote Reply
Re: altavista search - new mod In reply to
I am having problems running, this Links 2.0 mod. When I run it I get a 500 error.
I have tryed to install this mod a few times.

You can see my search.cgi file by gooing to http://hiphopbot.com/search.txt. You
can see my site_html_templates.pl file by gooing to http://hiphopbot.com/site_html_templates.txt

Can anyone tell me what I am dooing wrong?

------------------
Thank You,
James Hardy
HipHopBot Co.
support@hiphopbot.com
http://hiphopbot.com

[This message has been edited by wesmix (edited May 07, 2000).]

[This message has been edited by wesmix (edited May 07, 2000).]
Quote Reply
Re: altavista search - new mod In reply to
First of all... DON'T POST ANY MORE POSTS ON THIS MESSAGE...

use this message for page 2!

http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/005757.html


and add a ';' to the end of this line
Code:
$next = &next_hits($page, $link_hits, 10)



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

www.magicdirectory.com


> >