shell批量检查IP是否是百度蜘蛛

2025-10-18 22:44:06

1、 案例展示

# cat u_ex161127.log|grep Baiduspider|head -1

u_ex161127.log 是日志文件

shell批量检查IP是否是百度蜘蛛

2、收集所有的Baiduspider的ip,展示前10个。

# cat u_ex161127.log|grep Baiduspider|awk '{print $9}'|sort|uniq|head -10

shell批量检查IP是否是百度蜘蛛

3、将所有IP存入ip.txt

# cat u_ex161127.log|grep Baiduspider|awk '{print $9}'|sort|uniq > ip.txt

查看ip.txt中的ip数量

# cat ip.txt|wc -l

shell批量检查IP是否是百度蜘蛛

1、# 反查ip命令

nslookup ip

shell批量检查IP是否是百度蜘蛛

2、# 批量检查ip是否是真实Baiduspider,存入Baidu-ip.txt

# cat ip.txt|while read line;do nslookup $line|grep baiduspider|awk -F "baiduspider-" '{print $2}'|awk -F "." '{print $1}'|sed 's/-/\./g';done > baidu-ip.txt

注:while .. ;do ...;done 是循环语句

shell批量检查IP是否是百度蜘蛛

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢