【发布时间】:2020-09-25 20:18:04
【问题描述】:
有没有办法在 Python 脚本中执行以下命令,以自动化并在 s3 存储桶中获得预期的结果:
curl https://ip-ranges.amazonaws.com/ip-ranges.json |
jq -r '.prefixes[] | select(.service=="CLOUDFRONT") | "set_real_ip_from \(.ip_prefix);"
' > set_real_ip_from.inc
命令输出:
set_real_ip_from 34.216.51.0/25;
set_real_ip_from 34.223.12.224/27;
set_real_ip_from 34.223.80.192/26;
set_real_ip_from 34.226.14.0/24;
set_real_ip_from 35.158.136.0/24;
set_real_ip_from 35.162.63.192/26;
set_real_ip_from 35.167.191.128/26;
set_real_ip_from 44.227.178.0/24;
set_real_ip_from 44.234.108.128/25;
set_real_ip_from 44.234.90.252/30;
set_real_ip_from 52.15.127.128/26;
【问题讨论】:
-
是的,可以在python中发出http请求和解析json。
-
如果有任何参考文档可以完成,您可以分享一下吗?
标签: python amazon-web-services amazon-s3 jq