Does php determine whether a web crawler or a browser accesses a website?

Source: Internet
Author: User
It is used to distinguish between browser and web crawler access. the main implementation code is as follows: php determines whether a web crawler or a browser accesses a website? December 25, 2013 score 2.6, out of 5 stars 10 votes + Add comments 136 read

I added an access count to my blog last night.

The main implementation code is as follows:

// Determine whether the crawler function isCrawler () {$ userAgent = strtolower ($ _ SERVER ['http _ USER_AGENT ']); $ spiders = array ('googlebot ', // Google crawler 'baidider Ider ', // Baidu crawler 'Yahoo! Slurp ', // Yahoo crawler 'yodaobot', // Youdao crawler 'msnbot '// Bing crawler // more crawler keywords); foreach ($ spiders as $ spider) {$ spider = strtolower ($ spider); if (strpos ($ userAgent, $ spider )! = False) {return true;} return false ;}

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.