【发布时间】:2018-11-22 13:30:25
【问题描述】:
我有一个这种格式的 DNS 流量 JSON 文件
{
"index": {
"_type": "answer_query",
"_id": 0,
"_index": "index_name"
}
}
{
"answer_section": " ",
"query_type": "A",
"authority_section": "com. 172 IN SOA a.xxxx-xxxx.net. nstld.xxxx-xxxxcom. 1526440480 1800 900 604800 86400",
"record_code": "NXDOMAIN",
"ip_src": "xx.xx.xx.xx",
"response_ip": "xx.xx.xx.xx",
"date_time": "2018-05-16T00:57:20Z",
"checksum": "CORRECT",
"query_name": "xx.xxxx.com.",
"port_src": 50223,
"question_section": "xx.xxxx.com. IN A",
"answer_count_section": 0
}
我需要提取authority_section中空格后面的数字(在示例中为172)小于300的数据,忽略不符合要求的数据,然后将输出写入另一个JSON 文件。
我怎样才能做到这一点?谢谢
【问题讨论】:
-
显示你的尝试。
-
还为这种情况下的预期输出 (JSON) 编写一个示例。
-
@l'L'l 我对使用 Python 还是很陌生,所以我还没有任何像样的代码。
-
@Hemant_Negi 输出应该和输入的JSON文件有类似的结构,只有300以上的数据会被删除。