![]() |
|
![]() |
#1 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
Extracting H2 tag
Hi,
I have added the code you suggested to the robot_functions.php to pull the h2 tag instead of the title tag. It works but the problem is that it is pulling both the first and second h2 tags. This is the code i pasted in: //extracts title if (preg_match_all('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs,PREG_SET_ORDER)) { // assumes there are at least three h2 tags $title = trim($regs[0][1]." ".$regs[1][1]." ".$regs[2][1]); } else { $title = ""; } The results is showing " Contact UsContact Us" On this page there are 2 h2 tags. http://dobleweb1.doble.com/contactus/ but i only want to show the second one. Any suggestions? Thanks, -Marc |
![]() |
![]() |
![]() |
#2 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
If you only want the second H2 tag try:
Code:
$title = trim($regs[1][1]); Code:
$title = trim($regs[0][1]." ".$regs[1][1]." ".$regs[2][1]);
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#3 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
When i try that. It brings up "Untitled" and "search.php" for most of them
http://doble.phpslave.com/search.php -Marc |
![]() |
![]() |
![]() |
#4 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Are you using the following?
Code:
if (preg_match_all('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs,PREG_SET_ORDER)) { // assumes there are exactly two h2 tags $title = trim($regs[1][1]); } else { $title = ""; }
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#5 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
Here is the code
//extracts title if (preg_match_all('/< *h2 *>(.*?)< *\/ *h2 *>/is',$text,$regs,PREG_SET_ORDER)) { $title = trim($regs[1][1]); } else { $title = ""; } |
![]() |
![]() |
![]() |
#6 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Keep that code and increase CHUNK_SIZE in the config file, maybe 4096 will do. If not, try another increase so to get the two H2 tags in the same chunk.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#7 |
Green Mole
Join Date: Feb 2005
Posts: 11
|
That seems to have done the trick!
Thanks, -Marc ![]() |
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use variable in src tag | ravi | Coding & Tutorials | 1 | 06-15-2006 06:58 AM |
title tag | worldwealth | How-to Forum | 1 | 12-13-2005 04:19 PM |
Extracting search results and using them in your own web pages | ciaran@clissman | Mod Submissions | 1 | 11-26-2005 10:14 AM |
Display first H2 tag as title instead of page title | mdavila | How-to Forum | 5 | 02-27-2005 06:48 PM |
Custom Template Tag | garyp75 | How-to Forum | 1 | 08-09-2004 02:43 PM |