PHP Statistics nginx Access log search engine crawl 404 Link page path _php tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    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.