我有一个python脚本,它应该获取一个满是.txt文件的目录,并确定每个.txt文件是否返回正数或负数,以匹配文件本身中的某些文本语句,如“已知感染源”。但是,我的脚本运行了大约15秒,然后说它完成了。然而输出.csv脚本创建的文件为空。该.csv文件应包含真假约100000.txt文件任何帮助将不胜感激!你知道吗
代码
import os
import json
import csv
path="C:/Users/bwerner/Documents/output/"
def vt_result_check(path):
vt_result = False
for filename in os.listdir(path):
with open(path + filename, 'r') as vt_result_file:
vt_data = json.load(vt_result_file)
# Look for any positive detected referrer samples
# Look for any positive detected communicating samples
# Look for any positive detected downloaded samples
# Look for any positive detected URLs
sample_types = ('detected_referrer_samples', 'detected_communicating_samples',
'detected_downloaded_samples', 'detected_urls')
vt_result |= any(sample['positives'] > 0 for sample_type in sample_types
for sample in vt_data.get(sample_type, []))
# Look for a Dr. Web category of known infection source
vt_result |= vt_data.get('Dr.Web category') == "known infection source"
# Look for a Forecepoint ThreatSeeker category of elevated exposure
# Look for a Forecepoint ThreatSeeker category of phishing and other frauds
# Look for a Forecepoint ThreatSeeker category of suspicious content
threats = ("elevated exposure", "phishing and other frauds", "suspicious content")
vt_result |= vt_data.get('Forcepoint ThreatSeeker category') in threats
vt_result = int(vt_result)
return vt_result
if __name__ == '__main__':
for i in range(vt_result_check(path)):
f = csv.writer(open("output.csv", "wb+"))
print(vt_result_check(path))
f.writerow(vt_result_check(path))
目前没有回答
相关问题 更多 >
编程相关推荐