是否有xml.etree.ElementTree模块的等效项?

问题描述 投票:2回答:1

我正在使用下面的代码解析一堆XML元素。

import pandas as pd
import datetime
import requests
import pandas_gbq
import xml.etree.ElementTree
REQUEST_URL = 'https://www.corporate-site/report-api/?obj_device=47116&Yesterday'
response = requests.get(REQUEST_URL, auth=(login, password))
xml_data = response.text.encode('utf-8', 'ignore') 

root = xml.etree.ElementTree.fromstring(xml_data)

desc = root.get("Description")

上面的代码在我的客户端Python 3.6设置中运行得非常好。我将此问题转移到Google Cloud功能有一个大问题,因为显然Google无法识别此xml.etree.ElementTree模块。有没有人在这里使用谷歌云功能?如果是这样,有没有办法让远程服务器端环境设置与本地环境相匹配?或者,是否有相当于xml.etree.ElementTree模块,它可以很好地解析XML语法?谢谢大家。

python python-3.x google-cloud-platform google-cloud-functions libxml2
1个回答
2
投票

您可以在System Packages list中查看Python函数的当前支持的包中的Cloud Functions。

快速搜索,似乎唯一支持的与XML相关的模块是libxml2。您可以查看此库here的文档。同样可以检查这个库的Python绑定如何工作in this examples

同样,如果这个库不足以满足您想要使用云功能的用途,您可以在issue tracker中发出功能请求,以请求实现您请求的库。这是用于创建新功能请求的direct link

© www.soinside.com 2019 - 2024. All rights reserved.