PHP code design crawler record database
create table crawler ( crawler_ID bigint() unsigned not null auto_increment primary key, crawler_category varchar() not null, crawler_date datetime not null default '-- ::', crawler_url varchar() not null, crawler_IP varchar() not null)default charset=utf;
Php code
-) {$ Bot = "Other Crawler";} if (strpos ($ agent, "googlebot")>-) {$ Bot = "Google ";} if (strpos ($ agent, "mediapartners-google")>-) {$ Bot = "Google Adsense";} if (strpos ($ agent, "baiduspider")> -) {$ Bot = "Baidu";} if (strpos ($ agent, "sogou spider")>-) {$ Bot = "Sogou";} if (strpos ($ agent, "yahoo")>-) {$ Bot = "Yahoo! ";} If (strpos ($ agent," msn ")>-) {$ Bot =" MSN ";} if (strpos ($ agent," ia_archiver ")> -) {$ Bot = "Alexa";} if (strpos ($ agent, "iaarchiver")>-) {$ Bot = "Alexa";} if (strpos ($ agent, "sohu")>-) {$ Bot = "Sohu";} if (strpos ($ agent, "sqworm")>-) {$ Bot = "AOL ";} if (strpos ($ agent, "yodaoBot")>-) {$ Bot = "Yodao";} if (strpos ($ agent, "iaskspider")> -) {$ Bot = "Iask";} require (". /dbinfo. php "); date_defau Lt_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 () ;}?>
Html display
Num_rows ($ mysql-> query ("select * from crawler"); $ pages = new PageClass ($ count, $ _ 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 ();?>