import requests
import os
import time
import xlrd
import xlwt
import threading
import threadpool
import socket
class compare_app():
def init(self,path1,path2):
self.dict1={}
self.dict2={}
self.dict3={}
self.path1=path1
self.path2=path2
def app_pipe(self):
for root, dirs, files in os.walk(self.path1):
List1=files
print(List1) #当前路径下所有非目录子文件
for file in files:
data=xlrd.open_workbook('D:\\excel\\%s' %file,ragged_rows = True)
table=data.sheets()[0]
#print('----------------------------------------')
for row_index in range(table.nrows):
dstip = table.cell(rowx=row_index,colx=4).value
app_name=table.cell(rowx=row_index,colx=6).value
if dstip not in self.dict1 and dstip!="目的IP":
self.dict1[dstip]=app_name
else:
continue
#for key,value in self.dict1.items():
# print( key+',',value)
for root, dirs, files in os.walk(self.path2):
List2=files
print(List2) #当前路径下所有非目录子文件
for file in files:
data=xlrd.open_workbook('D:\\excel1\\%s' %file,ragged_rows = True)
table=data.sheets()[0]
#print('----------------------------------------')
for row_index in range(table.nrows):
dstip = table.cell(rowx=row_index,colx=4).value
app_name=table.cell(rowx=row_index,colx=6).value
if dstip in self.dict1 and dstip!="目的IP":
self.dict2[dstip]=app_name
else:
continue
#输出白名单误识别的目的IP和应用
for key,value in self.dict2.items():
print( key+',',value)
if name == ‘main’:
pipei1=pipei(‘C:\Users\ThinkPad\Desktop\kl\URL_IP.xlsx’)
# pipei1.url_pipe()
#白名单应用目录:‘D:\excel1’
#误识别应用目录:‘D:\excel’
yuming1=compare_app(‘D:\excel’,‘D:\excel1’)
yuming1.app_pipe()