Use a PHP program to know if a spider has visited your website (with code

Source: Internet
Author: User
Search engine spider visit websites are carried out by remotely capturing pages. we cannot use JS code to obtain the spider Agent information, but we can use the image tag, in this way, we can obtain the agent material of the spider.

Search engine spider visit websites are carried out by remotely capturing pages. we cannot use JS code to obtain the spider Agent information, but we can use the image tag, in this way, we can obtain the agent material of the Spider. by analyzing the agent material, we can determine the types, gender, and other factors of the spider, we can record statistics through databases or text.
Database structure:
#
# Table structure 'Naps _ stats_bot'
#

Create table 'Naps _ stats_bot '(
'Botid' int (10) unsigned not null auto_increment,
'Botname' varchar (100) not null default '',
'Botagent' varchar (200) not null default '',
'Bottag' varchar (100) not null default '',
'Botcount' int (11) not null default '0 ',
'Botlast 'datetime not null default '2017-00-00 00:00:00 ',
'Botlasturl' varchar (250) not null default '',
Unique key 'botid' ('botid '),
KEY 'botname' ('botname ')
) TYPE = MyISAM AUTO_INCREMENT = 9;

#
# Export the table data 'Naps _ stats_bot'
#

Insert into 'Naps _ stats_bot 'VALUES (1, 'googlebot', 'googlebot/2.X (http://www.googlebot.com/bot.html) ', 'googlebot', 0, '2017-00-00 00:00:00 ', '');
Insert into 'Naps _ stats_bot 'VALUES (2, 'msnbot', 'msnbot/0.1 (http://search.msn.com/msnbot.htm) ', 'msnbot', 0, '2017-00-00 00:00:00 ', '');
Insert into 'Naps _ stats_bot 'VALUES (3, 'inktomi slurp', 'slurp/123456', 'slurp', 0, '2017-00-00 00:00:00 ', '');
Insert into 'Naps _ stats_bot 'VALUES (4, 'baidider Ider', 'baidider Ider (http://www.baidu.com/search/spider.htm) ', 'baidider Ider', 0, '2017-00-00 00:00:00 ', '');
Insert into 'Naps _ stats_bot 'VALUES (5, 'yahoobot', 'mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp) ', 'slurp', 0, '2017-00-00 00:00:00 ','');
Insert into 'Naps _ stats_bot 'VALUES (6, 'sohubot', 'sohu-search', 'sohu-search', 0, '2017-00-00 00:00:00 ', '');
Insert into 'Naps _ stats_bot 'VALUES (7, 'lycos', 'lycos/x. x', 'lycos ', 0, '2017-00-00 00:00:00 ','');
Insert into 'Naps _ stats_bot 'VALUES (8, 'robozilla', 'robozilla/123456', 'robozilla ', 0, '2017-00-00 00:00:00 ','');

PHP program:
/*************************************** ************************************
* NAPS -- Network Article Publish System
*----------------------------------------------
* Bot. php
*-------------------
* Begin: 2004-08-15
* Copyright: (C) 2004 week9
* Email: wapshow@gmail.com
* Homepage: http://www.week9.com

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.