python - Take API data from XML and do another API call using Python3
问题描述
I've got XML API data from which I need to take a value and run another API call from it.
<?xml version="1.0" encoding="ISO-8859-1"?>
<result status="OK" host="systemmonitor.co.uk" created="2018-10-26T09:45:27+01:00">
<client>
<clientid>12345</clientid>
</client>
<client>
<clientid>67890</clientid>
</client>
There's about 100 clients in this file and what I need is to be able to take the ClientID value for each one and run it through another API call (I'm assuming I can set it as a variable?)
How would I go about taking the multiple client IDs and running them through api calls to get more data?
解决方案
您可以使用ElementTree
来提取数据,然后将其输入到列表中以进行第二次 API 调用。这篇文章可能会有所帮助:
Extracting text from XML using python
推荐阅读
- python - Python大写字符串列表
- bash - 使用 bash 将内容附加到 ROOT 文件?
- android - 错误:使用 JsonReader.setLenient(true) 在第 1 行第 1 列路径 $ 接受格式错误的 JSON
- c# - C# 用户击键未注册
- python - 在循环内合并数据框 - 熊猫很慢
- amazon-web-services - AWS 自定义授权方超时
- sql - SQL中子查询的替代方案?
- svn - svn propset svn:auto-props :递归地为整个存储库设置多个文件,如何?
- python - Django ModelForm 和 mock.patch.object 打破单元测试隔离?
- azure-powershell - 如何使用 powershell 命令 Set-AzureRmLogicApp 更改逻辑应用的参数?