python3扫描周围蓝牙设备_python3-网站路径扫描

importhashlibimportaiohttpimportasynciofrom multiprocessing importProcess, Queue, Manager#"""#aiohttp:发送http请求#1.创建一个ClientSession对象#2.通过ClientSession对象去发送请求(get, post, delete等)#3.await 异步等待返回结果#"""

classDirscan():def __init__(self,target):

self.target=target

self.targetmd5= ''self.allqueue=Queue()

self.urlpath=r'字典文件' #字典文件,可以修改

self.Ansdomain =Manager().list()

self.processnum= 8 #进程数 可以修改

self.alldictnum=0defdicturl(self):

with open(self.urlpath,'r',encoding='utf-8') as f:for i inf.readlines():

self.allqueue.put(self.target+'/'+i.strip('\n'))

self.alldictnum=self.allqueue.qsize()

asyncdefmain(self,url):

async with aiohttp.ClientSession() as session:

async with session.get(url) as res:

htmlstr=await res.text()

md5hash= hashlib.md5(htmlstr.encode("utf8"))

md5=md5hash.hexdigest()returnres.status,md5defdirscan(self):

loop=asyncio.get_event_loop()

task=loop.create_task(self.main(self.target))

status, self.targetmd5=loop.run_until_complete(task)while self.allqueue.empty() !=True:

tmp=self.allqueue.get()

task=loop.create_task(self.main(tmp))try:print('\r'+str(int(self.alldictnum)-int(self.allqueue.qsize()))+'/'+str(int(self.alldictnum)),end='')

status,mad5=loop.run_until_complete(task)#print('bad : '+tmp)

if ((status==200) and (mad5!=self.targetmd5)):print('OK :'+tmp)

self.Ansdomain.append(tmp)exceptException as e:print(e)defSetProcess(self):

self.dicturl()

allprocess=[]for i inrange(0, self.processnum):

p= Process(target=self.dirscan, args=())

p.start()

allprocess.append(p)for i inallprocess:

i.join()for i inallprocess:

i.close()if __name__ == '__main__':

obj= Dirscan('http://4399.com')

obj.SetProcess()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值