首页 > 解决方案 > 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?

标签: pythonxmlapivariables

解决方案


您可以使用ElementTree来提取数据,然后将其输入到列表中以进行第二次 API 调用。这篇文章可能会有所帮助: Extracting text from XML using python


推荐阅读