You can use the HTTP_USER_AGENT to check those bots or spiders and block them. Here I am blocking some of the well-known bad bots. When these bots will try to access the page, 403 will be returned.
## block these botsRewriteEngine OnRewriteCond %{HTTP_USER_AGENT} (AhrefsBot|SemrushBot|Barkrowler|MJ12bot|DotBot|Java|DataForSeoBot|BLEXBot) [NC]RewriteRule .* - [F,L]