python xml scraper
hi, is there any way to run a full-fledged python script in HA? I have a germ of an xml scraper here, which normally works, for example, on Linux Debian. can it be run here too?
import requests
from lxml import etree
login_url = "http://10.55.254.5"
data_url = "http://10.55.254.5/PAGE130.XML"
username = "*****"
password = "*****"
login_data = {
"USER": username,
"PASS": password
}
with requests.Session() as session:
response = session.post(login_url, data=login_data)
if response.status_code == 200:
data_response = session.get(data_url)
if data_response.status_code == 200:
xml_content = data_response.content
xml_tree = etree.fromstring(xml_content)
data = xml_tree.xpath("//*")
for element in data:
print(etree.tostring(element, encoding="unicode"))
else:
print("Error:", data_response.status_code)
else:
print("Error:", response.status_code)