Excerpts from search result page

K

Krishna Srinivasan

Hi All,

I have written a website search script that returns all the pages that
match 100% with the search terms. I also want to include excerpts from
the returned result page with the search terms bolded (as Google does
below the title of the retuned page). Is there a ready Perl script
that does just this? Or will I have to write one myself. There seems
to be a thousand different cases on how the excerpt will contain the
search term(s).

Thanks in advance.

Krishna Srinivasan.
 
N

news

Krishna Srinivasan said:
I also want to include excerpts from
the returned result page with the search terms bolded

The trivial case doesn't seem to be that hard to me.

I will assume you're producing HTML results, and that you've remembered
to strip all HTML from the search results themselves.

foreach my $summary (find_page_summaries(@search_terms)) {
my $re = '\b(' . join ('|', @search_terms) . ')\b';
$summary =~ s!$re!<b>$term</b>!g;
print "<p>$summary</p>\n";
}

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,819
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top