I have the habit of cutting nginx log on the server every day, so for every major search engine visit, always record some 404 page information, traditionally I just occasionally analyzed the log, but for a lot of log information friends, manual to screen may not be an easy thing, This is not my personal slowly study a little, for Google, Baidu, search, 360 search, appropriate search, Sogou, Bing and other search engine 404 access to a txt text file, directly on the code test.php.
Copy the Code code as follows:
<?php
Visit test.php?s=google
$domain = ' http://www.jb51.net ';
$spiders =array (' baidu ' = ' baiduspider ', ' 360Spider ',
' Google ' = ' Googlebot ', ' soso ' = ' sosospider ', ' sogou ' + =
' Sogou Web spider ', ' easou ' = ' easouspider ', ' Bing ' and ' Bingbot ');
$path = '/home/nginx/logs/'. Date (' y/m/'). (Date (' d ')-1). ' /access_www.txt ';
$s =$_get[' s '];
if (!array_key_exists ($s, $spiders)) Die ();
$spider = $spiders [$s];
$file = $s. ' _ '. Date (' ym '). (Date (' d ')-1). TXT ';
if (!file_exists ($file)) {
$in =file_get_contents ($path);
$pattern = '/get (. *) http\/1.1 ' 404.* '. $spider. ' /';
Preg_match_all ($pattern, $in, $matches);
$out = ";
foreach ($matches [1] as $k = + $v) {
$out. = $domain. $v. " \ r \ n ";
}
File_put_contents ($file, $out);
}
$url = $domain. ' /silian/'. $file;
echo $url;
Okay, that's it. There is no advanced technology, only the process of writing.
http://www.bkjia.com/PHPjc/824747.html www.bkjia.com true http://www.bkjia.com/PHPjc/824747.html techarticle I have the habit of cutting nginx log on the server every day, so for every major search engine visit, always record some 404 page information, traditionally I just occasionally analyze the log, but ...