...

View Full Version : graping meta description like a searchbot



iota
03-25-2007, 05:18 PM
Hi

I'm finding a difficulty in graping meta description like a searchbot because of
its flexible patterns.

<meta content="This is my web site description" name="description" />
<meta name="description" content="This is my web site description" />

I've tried with the following patterns but in vain :


preg_match('@(?:<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+(.*\w+)@i',

preg_match('@(?:<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+([^"|/>|>]+)@i',

preg_match('@(<meta content="|<meta content="|<meta name="description" content="|<meta content=|<meta name=description content=)+(.*)([^"]).(name="description" />|name=description>|>|>|/>|"/>|)@i',



I'd like to get the

This is my web site description.

iLLin
03-25-2007, 06:46 PM
Something to fool with/another idea


while(true)
{
$begPos = strpos($contents,"<meta");
if ($begPos===false) break;.
$endPos = strpos($contents,">",$begPos+strlen("<meta"));

//search for your name and contents here within the tag...

if ($loopcontrol++>100) break; //loop infinity control
continue; //search again
}

iLLin
03-25-2007, 07:05 PM
$description = strpos($contents, "description=\"");
//then end it
//I would also search for the dink (') too. Maybe setup an array of possible values?
//Not sure but I think they HAVE to wrap the description in quotes?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum