我正在使用python使用API curl命令拉取日志。
curl -H "Authorization:Token xxxxxxxx-xxxx-xxxxx" -XGET https://my-api.holmsecurity.com/v2/net-scans
我想过滤这个卷曲输出,说"过去 24 小时"。
API 支持 ISO 8601 格式(例如 2022-03-01T10:00:00Z(,也支持 UTC 偏移量(例如 2022-03-01T11:00:00+0100(
谢谢。
你必须使用 python 的请求包。
一个典型的例子是这样的:
# importing the requests library
import requests
# api-endpoint
URL = "https://my-api.holmsecurity.com/v2/net-scans"
header = {'Authorization': 'Token xxxxxxxx-xxxx-xxxxx'}
# sending get request and saving the response as response object
r = requests.get(url = URL, headers = header)
# extracting data in json format
data = r.json()
//Now you can filter your data
print(data)