sh 脚本识别搜索引擎蜘蛛
白名单的
shell
脚本istrustip.sh
basepath='/usr/local/openresty/nginx/conf/lua/sh' echo $1 | grep -f $basepath/trust_ips.txt | awk '{if($0) print 1}'
trust_ips.txt
^42.236.101.* ^42.236.102.* ^42.236.103.* ^42.236.10.* ..
反查IP 的
shell
脚本isspider.sh
# 反查IP 45.152.11.106.in-addr.arpa domain name pointer shenmaspider-106-11-152-45.crawl.sm.cn.
basepath='/usr/local/openresty/nginx/conf/lua/sh'
hostname=`host $1 | grep -f $basepath/spider.txt | awk '{print $5}'`
if [ ! -z $hostname ];
then
# 反查域名 shenmaspider-106-11-152-45.crawl.sm.cn has address 106.11.152.45
hostip=`host $hostname | awk '{print $4}'`
if [ "$hostip" = "$1" ];
then
echo 1
exit
fi
fi
echo 0
spider.txt
sm.cn
baidu.com
baidu.jp
sogou.com
bytedance.com
msn.com
googlebot.com
本作品采用《CC 协议》,转载必须注明作者和本文链接