json - 解析 curl 输出
问题描述
我正在尝试解析curl
请求并解析输出并将其存储在一个名为res.txt
这是我的 bash cmd 行:
curl --request POST --url 'https://www.virustotal.com/vtapi/v2/url/scan' --data 'apikey=XXXXXXXXXXXXXXX' --data 'url=abcde.xyz' >> grep -Po '"scan_id":.*?[^\\]",' res.txt
输出是这样的:
{"permalink": "https://www.virustotal.com/gui/url/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/detection/u-17f485d68047604e61b4067310ab716ae6fddc774bb46ffab06d081613b28e49-1595992331", "resource": "http://abcde.xyz/", "url": "http://abcde.xyz/", "response_code": 1, "scan_date": "2020-07-29 03:12:11", "scan_id": "000000000000000000000000000000000000000", "verbose_msg": "Scan request successfully queued, come back later for the report"}`
我想在 res.txt 上存储scan_id代码,但它不起作用,没有错误!而且我不知道我的正则表达式是否正确
你能帮助我吗?
解决方案
尝试
curl --request POST --url 'https://www.virustotal.com/vtapi/v2/url/scan' --data 'apikey=XXXXXXXXXXXXXXX' --data 'url=abcde.xyz'| tr ',' '\n' | grep scan_id
演示:
$"http://abcde.xyz/", "url": "http://abcde.xyz/", "response_code": 1, "scan_date": "2020-07-29 03:12:11", "scan_id": "000000000000000000000000000000000000000", "verbose_msg": "Scan request successfully queued, come back later for the report"}' <
{"permalink": "https://www.virustotal.com/gui/url/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/detection/u-17f485d68047604e61b4067310ab716ae6fddc774bb46ffab06d081613b28e49-1595992331", "resource": "http://abcde.xyz/", "url": "http://abcde.xyz/", "response_code": 1, "scan_date": "2020-07-29 03:12:11", "scan_id": "000000000000000000000000000000000000000", "verbose_msg": "Scan request successfully queued, come back later for the report"}
$: "000000000000000000000000000000000000000", "verbose_msg": "Scan request successfully queued, come back later for the report"}' | tr ',' '\n' | grep scan_id <
"scan_id": "000000000000000000000000000000000000000"
$
推荐阅读
- spring-boot - 使用 JWT 令牌的 Spring Boot webflux 安全性
- windows - Docker 容器与虚拟机
- java - java打印接口的arraylist
- perl - 如何在带有参数的草莓 perl 便携式 5.10.0.1 中运行文件?
- android - 不知何故,http请求的catchError无法使用cordova
- java - 如何延迟加载所有 Spring bean,无论它是由 Springboot 2.2 中的 @Bean 还是 @Component 定义的
- docker - 将使用 Docker 容器运行的网站从 HTTP 转换为 HTTPS
- android - Android:Okhttp3:SocketTimeoutException:无法连接到 dns/xx.xx.xx.xx(端口 443)
- php - 由于错误“cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书”而无法获取文件
- angular - 为什么 Angular 在其源代码中使用静态类而不是导出函数?