禁止SemrushBot蜘蛛爬取网站

发布时间:2023-05-09浏览次数:299 次
最近在查看日志文件的时候发现又出现一个很讨厌的新蜘蛛SemrushBot,UA标识为:Mozilla/5.0 (compatible; SemrushBot/7

最近在查看日志文件的时候发现又出现一个很讨厌的新蜘蛛SemrushBot,UA标识为:Mozilla/5.0 (compatible; SemrushBot/7~bl; +http://www.semrush.com/bot.html,经查,SemrushBot是SEMrush的服务器搜索蜘蛛,不过对中文网站没有什么用 SEMrush 是一个强大的、全面的在线营销竞争情报平台,其中包括 SEO、PPC、社交媒体和视频广告研究。首先不管它多强大,至少每天在别人的网站上爬几万次这种行为,就很惹人厌。

我们之前也分享过一篇《网站禁止垃圾搜索引擎爬虫访问的方法》,但是当时我们没有涉及到SemrushBot,因此今天我们继续将其加入禁止爬取的列表中。

一、robots.txt禁止爬取

首先在robots.txt文件中,我们添加如下内容:

User-agent: SemrushBot
Disallow: /
User-agent: SemrushBot-SA
Disallow: /
User-agent: SemrushBot-BA
Disallow: /
User-agent: SemrushBot-SI
Disallow: /
User-agent: SemrushBot-SWA
Disallow: /javascript:;
User-agent: SemrushBot-CT
Disallow: /
User-agent: SemrushBot-BM
Disallow: /
User-agent: SemrushBot-SEOAB
Disallow: /

但是我们都知道,很多蜘蛛是对robots.txt文件是不会及时处理的,甚至根本不会理会robots。因此,我们还需要在服务器端进行禁止。

二、从服务器端禁止爬取:

在我们的服务器网站运行环境中添加如下配置信息:

if ($http_user_agent ~* "Bytespider|PetalBot|AhrefsBot|SemrushBot|JikeSpider") {
	return 403;
}

至此,基本就可以防御这类爬虫爬取我们的网站了。

扫一扫,在手机上查看