Php - Php detect crawler script, Php function to detect crawler

Php detect crawler script

Detect crawlers using PHP script
Very simple php function used to analyze $_SERVER['HTTP_USER_AGENT'] variable and looking for crawler signature. If function founds crawler, it will return it's name, otherwise the php sccript will return false.

function crawlerDetect($USER_AGENT)
{
$crawlers = array(array('Google', 'Google'),
array('msnbot', 'MSN'),
array('Rambler', 'Rambler'),
array('Yahoo', 'Yahoo'), 
array('AbachoBOT', 'AbachoBOT'),
array('accoona', 'Accoona'),
array('AcoiRobot', 'AcoiRobot'),
array('ASPSeek', 'ASPSeek'), 
array('CrocCrawler', 'CrocCrawler'),
array('Dumbot', 'Dumbot'),
array('FAST-WebCrawler', 'FAST-WebCrawler'),
array('GeonaBot', 'GeonaBot'),
array('Gigabot', 'Gigabot'),
array('Lycos', 'Lycos spider'),
array('MSRBOT', 'MSRBOT'),
array('Scooter', 'Altavista robot'),
array('AltaVista', 'Altavista robot'),
array('IDBot', 'ID-Search Bot'),
array('eStyle', 'eStyle Bot'),
array('Scrubby', 'Scrubby robot'));

foreach ($crawlers as $c)
{
if (stristr($USER_AGENT, $c[0]))
{
return($c[1]);
}
}

return false;
}

// example

$crawler = crawlerDetect($_SERVER['HTTP_USER_AGENT']);

if ($crawler )
{
// it is crawler, it's name in $crawler variable

}
else
{
// usual visitor

}


This php script will detect the crawlers (i.e) the search engines which crawls your web site or web page.

The topic on Php - Php detect crawler script is posted by - Math

Hope you have enjoyed, Php - Php detect crawler scriptThanks for your time

Tech Bluff