Issue #2 resolved

bot check doesn't work.

fredsmith5473894
created an issue

The way it is currently coded, checking IGNORE_USER_AGENTS list and BOTS_USER_AGENTS list requires that the entire HTTP_USER_AGENT string is a perfect match which was obviously not the intention. Using the default BOTS_USER_AGENTS list will almost always fail unless the bot user agent only uses the word(s) in the list and nothing else.

Pattern matching it what should be done. So it only needs to match one or two words.

This should return True if anything in the user agent matches any word in the list.

ua_pattern = ""
for ua_pattern in settings.IGNORE_USER_AGENTS:
    if re.search(ua_pattern, request.META.get("HTTP_USER_AGENT",""):
        return True

return False

Comments (8)

  1. Log in to comment