Database Design: createtablecrawler (Fig (20) unsignednotnullauto_incrementprimarykey, Fig (20) notnull,
Database Design
create table crawler ( crawler_ID bigint(20) unsigned not null auto_increment primary key, crawler_category varchar(20) not null, crawler_date datetime not null default '0000-00-00 00:00:00', crawler_url varchar(50) not null, crawler_IP varchar(50) not null)default charset=utf8;
The following File robot. php records the crawler and writes the information to the database:
-1) {$ Bot = "Other Crawler";} if (strpos ($ agent, "googlebot")>-1) {$ Bot = "Google ";} if (strpos ($ agent, "mediapartners-google")>-1) {$ Bot = "Google Adsense";} if (strpos ($ agent, "baiduspider")> -1) {$ Bot = "Baidu";} if (strpos ($ agent, "sogou spider")>-1) {$ Bot = "Sogou ";} if (strpos ($ agent, "yahoo")>-1) {$ Bot = "Yahoo! ";}If (strpos ($ agent," msn ")>-1) {$ Bot =" MSN ";}if (strpos ($ agent," ia_archiver ")> -1) {$ Bot = "Alexa";} if (strpos ($ agent, "iaarchiver")>-1) {$ Bot = "Alexa ";} if (strpos ($ agent, "sohu")>-1) {$ Bot = "Sohu";} if (strpos ($ agent, "sqworm")>-1) {$ Bot = "AOL";} if (strpos ($ agent, "yodaoBot")>-1) {$ Bot = "Yodao";} if (strpos ($ agent, "iaskspider")>-1) {$ Bot = "Iask";} require (". /dbinfo. php "); date_default_timezone_set ('prc '); $ Shijian = date ("Y-m-d h: I: s", time (); // connect to the MySQL server $ connection = mysql_connect ($ host, $ username, $ password); if (! $ Connection) {die ('not ccted: '. mysql_error ();} // sets the active MySQL database $ db_selected = mysql_select_db ($ database, $ connection); if (! $ Db_selected) {die ('Can \'t use db :'. mysql_error ();} // insert data to the database $ query = "insert into crawler (fig, fig) values ('$ Bot', '$ shijian ', '$ getlocationurl',' $ serverip') "; $ result = mysql_query ($ query); if (! $ Result) {die ('invalid query: '. mysql_error () ;}?>
Now, you can access the database to know when the spider crawls your page.
Num_rows ($ mysql-> query ("select * from crawler"); $ pages = new PageClass ($ count, 25, $ _ GET ['Page'], $ _ SERVER ['php _ SELF ']. '? Page = {page} '); $ SQL = "select * from crawler order by"; $ SQL. = "crawler_date desc limit ". $ pages-> page_limit. ",". $ pages-> myde_size; $ result = $ mysql-> query ($ SQL);?>
|
Crawler access time |
Crawler category |
Crawler IP |
Crawler URL |
Fetch_array ($ result) {?>
|
|
|
|
|
Myde_write ();?>
Note: this article