mercredi 10 février 2016

Parsing XML Response from web

Hi i'm trying to parse this using requests.get and ElementTree with parse from string and it keeps telling me that it's a bad xml file xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0. I fetch the response from the api with requests and i tried to use different parsers. Here is what i'm trying :

import requests
from xml.etree import ElementTree

url = 'http://ift.tt/1TdeklX'
response = requests.get(url)
xmlstring = response.content # or response.text i dont know

parser = ElementTree.XMLParser(encoding="utf-8")
ElementTree.fromstring(xmlstring, parser=parser)`

I need to parse it in order to ask a specific var from it.




Aucun commentaire:

Enregistrer un commentaire