From 31b5c69a0615b35d0f645801657a2272c6f68692 Mon Sep 17 00:00:00 2001 From: Edgar Costa Date: Thu, 10 Aug 2023 12:48:37 -0400 Subject: [PATCH] very bad --- lmfdb/app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lmfdb/app.py b/lmfdb/app.py index bc0d650d90..0a02d9b261 100644 --- a/lmfdb/app.py +++ b/lmfdb/app.py @@ -297,6 +297,16 @@ def bad_bots_list(): for elt in [ "The Knowledge AI", "Wolfram", + "petalbot", + ] + ] + + +@cached_function +def very_bad_bots_list(): + return [ + elt.lower() + for elt in [ "Amazonbot", ] ] @@ -305,6 +315,9 @@ def bad_bots_list(): @app.before_request def badbot(): ua = request.user_agent.string.lower() + for elt in very_bad_bots_list(): + if elt in ua: + return render_template("404.html", title='Too many requests'), 429 for elt in bad_bots_list(): if elt in ua: time.sleep(10)