PHP record search engine spider visit Site footprint Method _php

Source: Internet
Author: User
Keywords PHP logging search engine spider access trail
This article describes the PHP record search engine spiders visit the site footprint method. Share to everyone for your reference. The specific analysis is as follows:

Search engine Spider Visit Web site is through the remote crawl page, we can not use the JS code to obtain the agent information of the spider, but we may through the image tag, so we can get the spider agent data, through the agent data analysis, you can determine the type of spider , gender and other factors, we can be counted through the database or the text to record.

Database structure:

The following is the referenced content:

# # Table structure ' Naps_stats_bot ' #CREATE table ' Naps_stats_bot ' (' botid ' int (ten) unsigned not NULL auto_increment, ' Botname ' varcha R (+) NOT null default ' ', ' botagent ' varchar ($) NOT null default ' ', ' bottag ' varchar (+) NOT null default ' ', ' botcount ' int ' is not null default ' 0 ', ' botlast ' datetime is NOT null default ' 0000-00-00 00:00:00 ', ' botlasturl ' varchar (+) not NUL L default ', UNIQUE key ' Botid ' (' Botid '), key ' Botname ' (' Botname ')) Type=myisam auto_increment=9; # # Export data in table ' Naps_stats_ Bot ' #INSERT into ' Naps_stats_bot ' VALUES (1, ' Googlebot ', ' googlebot/2.x (+http://www.googlebot.com/bot.html) ', ' Googlebot ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' VALUES (2, ' msnbot ', ' msnbot/0.1 (http://search.ms n.com/msnbot.htm) ', ' MSNBot ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' VALUES (3, ' Inktomi slurp ', ' Slur p/2.0 ', ' slurp ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' VALUES (4, ' Baiduspider ', ' baiduspider+ (+http ://www.baidu.com/search/spider.htm) ', ' Baiduspider ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' VALUES (5, ' Yahoobot ', ' mozilla/5.0+ (compatib LE;+YAHOO!+SLURP;+HTTP://HELP.YAHOO.COM/HELP/US/YSEARCH/SLURP) ', ' slurp ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' VALUES (6, ' Sohubot ', ' sohu-search ', ' Sohu-search ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' naps_stats _bot ' VALUES (7, ' Lycos ', ' lycos/x.x ', ' Lycos ', 0, ' 0000-00-00 00:00:00 ', '); INSERT into ' Naps_stats_bot ' values (8, ' Rob Ozilla ', ' robozilla/1.0 ', ' Robozilla ', 0, ' 0000-00-00 00:00:00 ', ';

The PHP program is as follows:

The following is the referenced content:

<?php/************************* NAPS--Network article Publish system*------------------------------------------ ----* bot.php*-------------------* begin:2004-08-15*************************//************************** Thi S program was free software; Can redistribute it and/or modify* it under the terms of the GNU general public License as published by* Ftware Foundation; Either version 2 of the license.*************************//************************** NAPs product is free software. You may and must reproduce, modify and distribute NAPs products in accordance with the provisions of the GNU GPL-GNU general Public License. Any derivative distributions based on NAPs products do not have to go through a floating license. /error_reporting (E_all & ~e_notice); function Get_naps_bot () {$useragent = Strtolower ($_ server[' http_user_agent '); if (Strpos ($useragent, ' Googlebot ')!== false) {return ' Googlebot ';} if (Strpos ($useragent, ' MSNBot ')!== false) {Retur n ' msnbot '; } if (Strpos ($useragent, ' slurp ')!== false) {return ' Yahoobot ';} if (Strpos ($useragent, ' Baiduspider ')!== false) {RET Urn ' BaiduspiDer '; } if (Strpos ($useragent, ' Sohu-search ')!== false) {return ' Sohubot ';} if (Strpos ($useragent, ' Lycos ')!== false) {Retu RN ' Lycos ';     } if (Strpos ($useragent, ' Robozilla ')!== false) {return ' Robozilla ';} return false;} $TLC _thispage = addslashes ($_server[' http_user_agent '));//Add Spider's fetch record $searchbot = Get_naps_bot (); if ($searchbot) {$DB _ Naps->query ("UPDATE naps_stats_bot SET botcount=botcount+1, Botlast=now (), botlasturl= ' $TLC _thispage ' WHERE Botname= ' $searchbot ');}? >

I hope this article is helpful to everyone's PHP programming.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.