Python这个用起来确实很方便,最近写了不少小东西,就分享给大家。今天是一个简单查询百度蜘蛛的真假。
QQ截图20160128180922# -*- coding: cp936 -*-import sys, socket#打开存放百度蜘蛛IP的文件spiderip = open('spiderip.txt','r')#判断IP类型for ip in spiderip:ip = ip.strip('\n')try:result = socket.gethostbyaddr(ip)if 'baiduspider' in result[0]:print ip,'百度蜘蛛'else:print ip,'假蜘蛛'except socket.herror, e:print ip,'找不到服务器'喜欢python,seo的同学可以关注我的QQ群472779600,个人博客
