恶意的蜘蛛行为不光会造成服务器的压力,并且对seo没有实质性用处,下面就拿SemrushBot蜘蛛为例来说明如何防止恶意爬取
SemrushBot蜘蛛原型
SemrushBot蜘蛛爬虫UA:"Mozilla/5.0 (compatible; SemrushBot/6~bl; +http://www.semrush.com/bot.html)"
为什么要屏蔽SemrushBot蜘蛛抓取
1、SemrushBot蜘蛛抓取过多增加网站服务器负担
2、SemrushBot不会给网站带来实质性帮助
SemrushBot蜘蛛爬虫屏蔽:通过robots.txt
User-Agent: SemrushBot
Disallow: /
注意:但是很多爬虫对robots.txt视若罔闻,照样来爬取本站的内容,那我们就从服务器端来屏蔽爬取的爬取
apache服务器通过.htaccess来屏蔽
RewriteCond %{HTTP_USER_AGENT} ".*(SemrushBot|GoogleBot).*" [OR]
ngnix服务器通过伪静态来屏蔽
#禁止Scrapy等工具的抓取
if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) {
return 403;
}
#禁止指定UA及UA为空的访问
if ($http_user_agent ~* "FeedDemon|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Cont