简体   繁体   English

如何从 URL 保存 XML 文件并使用 Python 将 XML 转换为 XSLX?

[英]How do I save an XML file from a URL and convert XML to XSLX using Python?

I need a python code to read XML file from this URL ( https://www.treasury.gov/ofac/downloads/consolidated/consolidated.xml ).我需要一个 python 代码来从这个 URL ( https://www.treasury.gov/ofac/downloads/consolidated/consolidated.xml ) 读取 XML 文件。 And convert this XML to XLSX file.并将此 XML 转换为 XLSX 文件。 So, this will be an automated code.所以,这将是一个自动代码。 Whenever i run this it will directly read from URL and it should save as XLSX.每当我运行它时,它都会直接从 URL 读取,它应该保存为 XLSX。 So that i will save in database on regular basis.这样我会定期保存在数据库中。

This link( https://cdkm.com/xml-to-xls ) is actually reading XML from URL and converting to XLSX(In which format i need).此链接( https://cdkm.com/xml-to-xls )实际上是从 URL 读取 XML 并转换为 XLSX(我需要哪种格式)。 But this is manual work.但这是手动工作。 we need automated one, so that we can run the code regularly.我们需要一个自动化的,这样我们就可以定期运行代码。

I have tried different methods, like convert XML to JSON to XLSX still not working.我尝试了不同的方法,比如将 XML 转换为 JSON 到 XLSX 仍然无法正常工作。 The main problem is that there are many columns which have same names.主要问题是有许多列具有相同的名称。 So, the conversion of XML to XLSX is not coming properly.因此,XML 到 XLSX 的转换无法正常进行。 Can any one please help me out solving this.谁能帮我解决这个问题。 Thanks in advance.提前致谢。

If with some filters and patterns on a python loop doesn't work, you can try creating a .NET bot, to combine your link ( https://cdkm.com/xml-to-xls ) with a web browser form.如果 python 循环上的某些过滤器和模式不起作用,您可以尝试创建一个 .NET 机器人,以将您的链接 ( https://cdkm.com/xml-to-xls ) 与 web 浏览器表单结合起来。

It exists some software to create bot on web browser form.它存在一些软件来创建 web 浏览器形式的 bot。 Sorry, I couldn't help you more.抱歉,我帮不了你更多。 But I hope it will help you, to find a good way to solve this task.但我希望它能帮助你找到解决这个任务的好方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM