I'm trying to create a realtime report using an API that allows me to grab the data I need and returns it in XML format. What I want to know is, after receiving the response, how can I save it to an .xml file locally? Or cache it, that way I can parse it before parsing the response.
import requests
r = requests.get('url', auth=('user', 'pass'))
I'm using requests since it's the easiest way to make a GET call in my opinion. Also, this is my first question and I'm barely starting to learn Python, I'd appreciate it if you guys had a little patience. Thanks.
I was looking at a similar question but for JSON, not sure if it would work the same, https://mcmap.net/q/544068/-saving-a-json-file-to-computer-python
import requests
import json
solditems = requests.get('https://github.com/timeline.json') # (your url)
data = solditems.json()
with open('data.json', 'w') as f:
json.dump(data, f)
file.open('foo.xml').write(r.text)
– Waggle