网络上的爬虫异常多,有对网站收录有益的,好比百度蜘蛛(Baiduspider),也有不但不遵守robots规则对服务器造成压力,还不能为网站带来流量的无用爬虫,好比宜搜蜘蛛(YisouSpider)。
进入到nginx安装目录下的conf目录,将如下代码保留为 agent_deny.conf
cd /usr/local/nginx/conf
vim agent_deny.conf
克制Scrapy等工具的抓取 if (http_user_agent ~ (Scrapy|Curl|HttpClient)) {return 403; } 克制指定UA及UA为空的接见 if (http_user_agent ~ quot;FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFee[湖北SEO]dParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^quot; ) {return 403; } 克制非GET|HEAD|方式的抓取 if (request_method !~ ^(GET|HEAD|)) {return 403; }
然后,在网站相关设置中的 location / { 之后插入如下代码:
include agent_deny.conf;
[湖北SEO]保留后,执行如下下令,平滑重启nginx即可:
/usr/local/nginx/sbin/nginx -s reload
模拟宜搜蜘蛛的抓取:
curl -I -A ‘YisouSpider’ 网站链接
效果返回403
模拟UA为空的抓取:
curl -I -A ” 网站链接
效果返回403
模拟百度蜘蛛的抓取:
curl -I -A ‘Baiduspider’ 网站链接
效果返回200
下面是网络上常见的垃圾UA列表
FeedDemon内容采集
BOT/0.1 (BOT for JCE) sql注入
CrawlDaddysql注入
Java内容采集
Jullo内容采集
Feedly内容采集
UniversalFeedParser 内容采集
ApacheBenchcc攻击器
Swiftbot无用爬虫
YandexBot无用爬虫
AhrefsBot无用爬虫
YisouSpider无用爬虫
jikeSpider无用爬虫
MJ12bot无用爬虫
ZmEu myadmin破绽扫描
WinHttp采集cc攻击
EasouSpider无用爬虫
HttpClienttcp攻击
Microsoft URL Control 扫描
YYSpider无用爬虫
jauntywordpress爆破扫描器
oBot无用爬虫
Python-urllib内容采集
Indy Library扫描
FlightDeckReports Bot 无用爬虫
(责任编辑:网络)

评论列表