GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-May-2004, 10:49
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Description / Excerpts off content in Search Engine Results Pages


When you search Google for the phrase: java forums and view the results listed on the SERPs, look at the description (or excerpts) off the web page just below each link.

Notice how it's extracted off the web page and just at the right points where the key words inside the search phrase appear (in bold / highlighted)?

I am just wondering if someone here can give me some ideas on how to go about doing this. Of course I don't expect any code examples, just the logic (or pseudocode) will do.

I realise that this question is not particularly related to PHP but since the functionality will be added to a PHP script, I thought I'd start the thread here.
  #2  
Old 19-May-2004, 16:04
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Hi JdS,
Sorry I havent visited for a while but I have been very busy.
Back to your problem....
If I understand you just want to highlight/bold the search keyword? If so I have done a database search (not finished yet but nearly) and to highlight the keyword or term I have used
Quote:
eregi_replace
for example my line of code is
Quote:
$str = strtoupper($_GET[queryStr]);
$content = eregi_replace($_GET[queryStr],'<span class="top_menu"><b>' . $str . '</b></span>',$row[Description]);

This converts the search term to Upper case and Bold. It also (using the class) highlights the background.
Hope this is what you want. If not Sorry.
  #3  
Old 20-May-2004, 05:41
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Thank you for the effort misunderstood, but I may not have explained my issue very well. I am not referring to the highlighting (I can do that with my eyes closed ), I am wondering how they got the excerpts done...

It looks simple but I REALLY can't think of a smart way to get this done.

If anyone has a problem trying to understand what exactly it is that I am after, take this whole page as an example. If I searched for the phrase "search", and this page is returned as link, the description for the contents off this page could look a bit like this:

Quote:
...you search Google for the phrase.... key words inside the search phrase... to highlight/bold the search keyword?... database search (not finished yet but nearly)...
  #4  
Old 20-May-2004, 07:29
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
I am confused now .
Are the pages you want to search html or database?
  #5  
Old 20-May-2004, 07:39
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Yes, I am sure you are - cause I am reading my last reply and I am also confused. Perhaps that's part of the problem...

Anyway, regardless of whether I am trying to get this off HTML or a database, I need some kind of a script to fetch the right bits off sentences on a web page containing the search phrase - hey! I think I explained it a bit better this time.
  #6  
Old 20-May-2004, 07:47
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Ahhh I see what you want. It did help that I have been reading about your search engine script
I was a liitle confused because I thought you was searching your own site database and displaying the results. Which would be simple to a man of your calibre.
  #7  
Old 20-May-2004, 07:50
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
It seems simple but it's not, I assure you. I have only been thinking about it for days now...
  #8  
Old 20-May-2004, 07:54
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
OK what about 'explode' search term, find each word seperately in text, bold/highlight each word, 'implode' and display? Or am I completely off track?
  #9  
Old 20-May-2004, 08:01
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Splitting the search term when there are multiple words in it, is done and working well.

Finding the sentences containing one or more of the keywords is the hard part. Harder still is knowing where to pick the start of a/the sentence and when to chop it off. Then it must be done for multiple pages (considering a single SERP may contain not less than 10 results / links).

I had something that worked ( using preg_match_all() ) BUT it was a monster of a script... took too much time and I didn't feel comfortable with it - came here to look for some inspiration or fresh ideas.
  #10  
Old 20-May-2004, 08:10
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Why not display the sentence or text where the first instant of all the words are present within a specified number of characters? If they are spread miles apart then the contect of the search would probably be irrelevant.
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Building a search engine and handling HTML entities. JdS Web Design Forum 2 27-Mar-2004 16:21
Please list your site on my search engine jake2003 Search Engine Optimization Forum 5 18-Dec-2003 13:46
Wayback machine releases the recall search engine jrobbio Web Design Forum 2 12-Sep-2003 14:40
How a search engine really works (In english) jrobbio Open Discussion Forum 0 06-Jul-2003 17:13
Search Engine Positioning 101 and 201 "How To" Tips... 000 Search Engine Optimization Forum 0 29-May-2003 10:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:25.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.