自用Nginx拦截爬虫规则,设置拦截规则。登录宝塔,点击网站--设置--伪静态 在里面添加下面代码即可。
if ($http_user_agent ~ semrush.com) {
return 403 ;
}
if ($http_user_agent ~ www.semrush.com) {
return 403 ;
}
if ($http_user_agent ~ webmaster.petalsearch.com) {
return 403 ;
}
if ($http_user_agent ~ ahrefs.com) {
return 403 ;
}
if ($http_user_agent ~ zhanzhang.toutiao.com) {
return 403 ;
}
##或者下面的
if ($http_user_agent ~* "SemrushBot|PetalBot|AhrefsBot|Googlebot") {
return 403;
}