我正在基于唯一数据对soap api执行请求。一些数据无效,给出空响应。我需要检查数据是否为null或包含xml。
from openpyxl import load_workbook
import requests
from xml.etree import ElementTree
wb = load_workbook("file path")
source = wb["Sheet1"]
for i, cniclist in enumerate(source['A']):
cust_no = cniclist.value
cust = source['B'][i]
cust_type = cust.value
url = "url" # I can't write valid url, header and payload data for security purpose
payload = "<CUSTID>{}</CUSTID>\r\n <CUSTTYPE>{}</CUSTTYPE>\r\n "
header = {}
现在,我需要在这里包括其他内容
response = requests.request("POST", url, data=payload.format(cust_no, cust_type), headers=headers)
tree = ElementTree.ElementTree(ElementTree.fromstring(response1.text))
root = tree.getroot()
如果任何请求包含空响应,则会出现以下错误:
返回parser.close()
xml.etree.ElementTree.ParseError:找不到元素:第1行,第0列