How to block bad User Agents

I noticed some user agents like python-requests contacting my site, and I wanna make sure only legit browsers can contact it, how do I do that?
Was this page helpful?