python解析xml
import requestsimport xml.etree.ElementTree as ETurl = 'http:///WebService/EcusWebService.asmx/get_ecar_bya?p_bya14={}'# GET /WebService/EcusWebService.asmx/get_ecar_bya?p_bya14=string HTTP/1.1# Host:
·
import requests
import xml.etree.ElementTree as ET
url = 'http:///WebService/EcusWebService.asmx/get_ecar_bya?p_bya14={}'
# GET /WebService/EcusWebService.asmx/get_ecar_bya?p_bya14=string HTTP/1.1
# Host: ecusweb9.efoxconn.com
car_num = 'C20163'
wbdata = requests.get(url.format(car_num))
print(wbdata)
print(wbdata.text)
root = ET.fromstring(wbdata.text)
name = root.find('.//BYA11').text
phone = root.find('.//BYA12').text
print('name', name)
print('phone', phone)
参考
https://stackoverflow.com/questions/69452755/how-to-parse-xml-from-string-in-python

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)