Giter Site home page Giter Site logo

Suggestion: detect bots about phpuseragent HOT 4 CLOSED

donatj avatar donatj commented on June 7, 2024
Suggestion: detect bots

from phpuseragent.

Comments (4)

donatj avatar donatj commented on June 7, 2024

They don't really have anything in common that I can grab onto, so it would require a hard coded list of "bots". That's not really practical at this point while still trying to keep this thing minimal I'm afriad.

from phpuseragent.

lucaferrario avatar lucaferrario commented on June 7, 2024

In my website I added a check to know if the client is a bot or not. After calling parse_user_agent, if $user_agent['platform'] is NULL I just run this regex, which seems reliable to detect all the major bots (considering that it is run after user agent detection failed, false positive are almost impossible). I paste it here in case it can be useful :-)
preg_match('/bot|crawl|slurp|spider|cloudflare/i', $_SERVER['HTTP_USER_AGENT'])

from phpuseragent.

luigifab avatar luigifab commented on June 7, 2024

(Now) there are some bots in Currently Detected Browsers.

echo $ua->platform() . PHP_EOL;
echo $ua->browser() . PHP_EOL;
echo $ua->browserVersion() . PHP_EOL;

Is it possible to add $ua->isBot()?

from phpuseragent.

donatj avatar donatj commented on June 7, 2024

@luigifab Per the README,

This is not meant as a browser "knowledge engine" but rather a simple parser. Anything not adequately provided directly by the user agent string itself will simply not be provided by this.

https://github.com/donatj/PhpUserAgent#what-it-does-not-do

There is no reliable way to know if something is a bot or not without maintaining a list of UA's known to be bots.

@lucaferrario 's method of checking if the platform is null may or may not be good enough for your purposes, but it's not reliable enough to codify.

from phpuseragent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.