Check if user_agent is a known bot.
552060
def _is_bot(user_agent):
    """"""
    bot_list = [
                'http://www.baidu.com/search/spider.html',
                'python-requests',
                'http://ltx71.com/',
                'http://drupal.org/',
                'www.sogou.com',
                'http://search.msn.com/msnbot.htm',
                'semantic-visions.com crawler',
               ]
    for bot in bot_list:
        if re.search(re.escape(bot), user_agent):
            return True
    return False
636002
protected function checkBrowserYandexMediaBot()
    {
        if (stripos($this->_agent, 'YandexMedia') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'YandexMedia'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion(str_replace(';', '', $aversion[0]));
                $this->_browser_name = self::BROWSER_YANDEXMEDIA_BOT;
                $this->setRobot(true);
                return true;
            }
        }
        return false;
    }
369036
def user_agent(style=None) -> _UserAgent:
    
    global useragent
    if (not useragent) and style:
        useragent = UserAgent()

    return useragent[style] if style else DEFAULT_USER_AGENT
77806
def check_robotstxt(url, session):
    
    roboturl = get_roboturl(url)
    rp = get_robotstxt_parser(roboturl, session=session)
    if not rp.can_fetch(UserAgent, str(url)):
        raise IOError("%s is disallowed by %s" % (url, roboturl))
128879
def check_api_key(email, api_key):
    """"""
    table = boto3.resource("dynamodb").Table(os.environ['people'])
    user = table.get_item(Key={'email': email})
    if not user:
        return False
    user = user.get("Item")
    if api_key != user.get('api_key', None):
        return False
    return user
1225636
async def _check_perm(self, session) -> bool:
        
        return await perm.check_permission(session.bot, session.ctx,
                                           self.permission)
698356
public function isHuman()
    {
        $browser = $this->getBrowser();
        if (empty($browser)) {
            return false;
        }

        if (preg_match('~(bot|crawl)~i', $browser)) {
            return false;
        }

        return true;
    }
439075
def _get_user_agent(self):
        
        user_agent = request.headers.get('User-Agent')
        if user_agent:
            user_agent = user_agent.encode('utf-8')
        return user_agent or ''
124305
public boolean isRobotPermitted(String url, String userAgent)
            throws IOException, RobotsUnavailableException {
        RobotRules rules = getRulesForUrl(url, userAgent);
        return !rules.blocksPathForUA(new LaxURI(url, false).getPath(),
                userAgent);
    }
643306
protected function checkBrowserYandexFaviconsBot()
    {
        if (stripos($this->_agent, 'YandexFavicons') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'YandexFavicons'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion(str_replace(';', '', $aversion[0]));
                $this->_browser_name = self::BROWSER_YANDEXFAVICONS_BOT;
                $this->setRobot(true);
                return true;
            }
        }
        return false;
    }
1139278
public boolean matchUserAgent(String userAgent) {
    if (anyAgent) return true;
    if (!anyAgent && userAgent==null) return false;
    return userAgents.stream().anyMatch(agent->agent.equalsIgnoreCase(userAgent));
  }
1328451
public function BD_CheckBotAgentAdvanced($UserAgent = false)
    {
        if ($UserAgent === false)
        {
                $UserAgent = trim(\Environment::get('httpUserAgent'));
        }
        return \BugBuster\BotDetection\CheckBotAgentExtended::checkAgentName( $UserAgent );
    }
1232076
def bot_watcher(self):
        
        default_interval = 5
        interval = default_interval
        while True:
            if not self.bot.connection.connected:
                if self.bot.reconnect():
                    interval = default_interval
                else:
                    interval *= 2
            sleep(interval)
1141312
protected function checkBrowserGoogleBot()
    {
        if (stripos($this->_agent, 'googlebot') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'googlebot'));
            $aversion = explode(' ', $aresult[1]);
            $this->setVersion(str_replace(';', '', $aversion[0]));
            $this->_browser_name = self::BROWSER_GOOGLEBOT;
            $this->setRobot(true);

            return true;
        }

        return false;
    }
750644
function DetectAmazonSilk()
   {
      if (stripos($this->useragent, $this->engineSilk) > -1)
         return $this->true; 
      else
         return $this->false; 
   }
1180366
public function isBot(): bool
    {
        if (null === $this->isBot) {
            $this->isBot = false;
            foreach ($this->botSignatures as $botSignature) {
                if (preg_match($botSignature, $this->name) === 1) {
                    $this->isBot = true;
                    break;
                }
            }
        }

        return $this->isBot;

    }
410913
def is_allowed(self, user_agent, url, syntax=GYM2008):
                
        if PY_MAJOR_VERSION < 3:
            # The robot rules are stored internally as Unicode. The two lines 
            # below ensure that the parameters passed to this function are 
            # also Unicode. If those lines were not present and the caller 
            # passed a non-Unicode user agent or URL string to this function,
            # Python would silently convert it to Unicode before comparing it
            # to the robot rules. Such conversions use the default encoding 
            # (usually US-ASCII) and if the string couldn't be converted using
            # that encoding, Python would raise a UnicodeError later on in the
            # guts of this code which would be confusing. 
            # Converting the strings to Unicode here doesn't make the problem
            # go away but it does make the conversion explicit so that 
            # failures are easier to understand. 
            if not isinstance(user_agent, unicode):
                user_agent = user_agent.decode()
            if not isinstance(url, unicode):
                url = url.decode()
        
        if syntax not in (MK1996, GYM2008):
            _raise_error(ValueError, "Syntax must be MK1996 or GYM2008")
    
        for ruleset in self.__rulesets:
            if ruleset.does_user_agent_match(user_agent):
                return ruleset.is_url_allowed(url, syntax)
                
        return True