You could, but it's tricky to get right I feel. Most small websites use a form of bot detection for visitors to manage this. This might be a service like Cloudflare or an open source thing like Anubis for example.
There's different ways to tackle this and it sucks we are forced into putting time and effort to deal with it.