-1
我正在使用VirusTotal API尝试编写将扫描并报告发现的脚本。我遇到的问题是代码的SCANS部分,我可以提取有多少是积极的或不是,但想要输出每个正面扫描和结果(病毒名称,网络钓鱼等)。JSON - 解析独立命名的子对象
例JSON:
{
'response_code': 1,
'verbose_msg': 'Scan finished, scan information embedded in this object',
'scan_id':'1db0ad7dbcec0676710ea0eaacd35d5e471d3e11944d53bcbd31f0cbd11bce31-1390467782',
'permalink': 'https://www.virustotal.com/url/__urlsha256__/analysis/1390467782/',
'url': 'http://www.virustotal.com/',
'scan_date': '2014-01-23 09:03:02',
'filescan_id': null,
'positives': 0,
'total': 51,
'scans': {
'CLEAN MX': {
'detected': false,
'result': 'clean site'
},
'MalwarePatrol': {
'detected': false,
'result': 'clean site'
}
}
}
我写的似乎并没有通过所有的扫描信息进入循环我似乎可以访问的唯一的事情是没有检测到防病毒扫描器名称代码/结果信息每。第一次使用JSON API时,任何帮助表示赞赏。
params = {'apikey': apikey, 'resource':line}
response = requests.get(vt_report_url, params=params)
result = response.json()
if result['positives'] != "0":
print "malware detection"
for avList in result['scans']:
if avList[1] == 'true':
print str(avList[0]) + " - "+ str(avList[2])
我给这个代码,去和它最初看起来像它会工作,但它没有通过的项目分解成一个数组就像我期待的那样。我在if语句上得到了一个关键错误,所以我在检查之前打印出了这个值,并且它没有像预期的那样将项目分开,而是返回了一行'{u'detected':False,u'result': u'clean site'}' – nilats
@nilats你从来没有提到你需要什么输出。 –
足够公平的,我的目标是提取AV名称和结果格式为“CLEAN MX - 干净的网站”/ n“MalwarePatrol - 干净的网站”为每个扫描 – nilats