本文介绍: 有的时候打开后台发现网站后台有各种莫名其妙的蜘蛛UA,而不是搜索引擎来过的,那么可能是被别人给爬取了,可以用下面方法屏蔽不明的蜘蛛UA,可根据网站实际情况来修改屏蔽蜘蛛UA对付这种垃圾蜘蛛最好方法就是按照访问规则查看对应的UA,按照UA规则,进行禁止访问,那么我们应该怎么做呢?

有的时候打开后台发现网站后台有各种莫名其妙的蜘蛛UA,而不是搜索引擎来过的,那么可能是被别人给爬取了,可以用下面方法屏蔽不明的蜘蛛UA,可根据网站实际情况来修改屏蔽蜘蛛UA

对付这种垃圾蜘蛛最好的方法就是按照访问规则查看对应的UA,按照UA规则,进行禁止访问,那么我们应该怎么做呢?

一:找到垃圾蜘蛛的UA特征

使用的是宝塔面板通过宝塔面板上的网站监控报表可以看到对应网站Nginx日志。如果你使用的不是宝塔面板,你可以将网站的日志下载下来。用notepad++或者其他代码编辑软件打开

二:针对特定UA进行屏蔽

屏蔽UA功能,是写在对应网站的nginx配置文件中的。

如果你使用的是宝塔面板配置路径如下

Nginx将以下代码加入配置文件server里:

if ($http_user_agent ~ "MegaIndex|MegaIndex.ru|BLEXBot|Qwantify|qwantify|semrush|Semrush|serpstatbot|hubspot|python|Bytespider|Go-http-client|Java|PhantomJS|SemrushBot|Scrapy|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|perl|Python|Wget|Xenu|ZmEu|^$" )
{
return 444;
}

IIS7/IIS8/IIS10及以上web服务请在网站根目录创建web.config文件,并写入如下代码即可:

<?xml version="1.0" encoding="UTF-8"?&gt;
<configuration&gt;
<system.webServer>
<rewrite>
<rules>
<rule name="Block spider">
<match url="(^robots.txt$)" 
ignoreCase="false" negate="true" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="MegaIndex|MegaIndex.ru|BLEXBot|Qwantify|qwantify|semrush|Semrush|serpstatbot|hubspot|python|Bytespider|Go-http-client|Java|PhantomJS|SemrushBot|Scrapy|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|perl|Python|Wget|Xenu|ZmEu|^$"
ignoreCase="true" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

IIS6请在isapi重写组件添加以下规则:

#Block spider
RewriteCond %{HTTP_USER_AGENT} (MegaIndex|MegaIndex.ru|BLEXBot|Qwantify|qwantify|semrush|Semrush|serpstatbot|hubspot|python|Bytespider|Go-http-client|Java|PhantomJS|SemrushBot|Scrapy|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|perl|Python|Wget|Xenu|ZmEu|^$) [NC]
RewriteRule !(^/robots.txt$) - [F]

Apache请在.htaccess文件添加如下规则

<IfModulmod_rewrite.c>
RewriteEngine On
#Block spider
RewriteCond %{HTTP_USER_AGENT} "MegaIndex|MegaIndex.ru|BLEXBot|Qwantify|qwantify|semrush|Semrush|serpstatbot|hubspot|python|Bytespider|Go-http-client|Java|PhantomJS|SemrushBot|Scrapy|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|perl|Python|Wget|Xenu|ZmEu|^$" [NC]
RewriteRule !(^robots.txt$) - [F]
</IfModule>

 

原文地址:https://blog.csdn.net/gukie/article/details/127857502

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_49064.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注