I'm trying parse XML from URL, but i got error FileNotFoundError
where I'm doing wrong?
Here's my code:
import xml.etree.ElementTree as ET
import requests
url = "http://cs.stir.ac.uk/~soh/BD2spring2022/assignmentdata.php"
params = {'data':'spurpyr'}
response = requests.get (url, params)
xml_content = response.content
tree = ET.parse(xml_content)
root = tree.getroot()
print(root.tag)
CodePudding user response:
ET.parse
parses from a file, instead of ET.parse
try using ET.fromstring
and that would probably help. I can't test your specific case since the URL you have written is giving me an error. So, try changing your code to this
import xml.etree.ElementTree as ET
import requests
url = "http://cs.stir.ac.uk/~soh/BD2spring2022/assignmentdata.php"
params = {'data':'spurpyr'}
response = requests.get (url, params)
xml_content = response.content
root = ET.fromstring(xml_content)
print(root.tag)