Python3.x:将数据下载到xls时候用xml格式保存一份读取内容
核心代码:
import json import xml.dom.minidom from urllib import request, parse from sqlalchemy import func dataDate = "2018-01-24" url = 'http://********/ShowReport.szse?SHOWTYPE=xml&CATALOGID=1804&ENCODE=1&TABKEY=tab1&txtDate=' + dataDate path = './1.xml' request.urlretrieve(url, path) file_xml = open(path, 'r', encoding='gbk').read() # 获取数据xml格式 file_xml = file_xml.replace( '<?xml version="1.0" encoding="GBK"?>', '<?xml version="1.0" encoding="utf-8"?>') xmldoc = xml.dom.minidom.parseString(file_xml) datas = xmldoc.getElementsByTagName('row')
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/16776.html