Improve bot detection

This commit is contained in:
R. Miles McCain 2020-04-19 10:28:01 -04:00
parent dba1d368a0
commit a5219c828b
No known key found for this signature in database
GPG Key ID: 91CB47BDDF2671A5

View File

@ -72,7 +72,11 @@ def ingress_request(
ua = user_agents.parse(user_agent)
initial = True
device_type = "OTHER"
if ua.is_bot or (ua.browser.family or "").strip() == "Googlebot":
if (
ua.is_bot
or (ua.browser.family or "").strip().lower() == "googlebot"
or (ua.device.family or ua.device.model or "").strip().lower() == "spider"
):
device_type = "ROBOT"
elif ua.is_mobile:
device_type = "PHONE"