A
A
AlmaShooter2016-06-08 17:13:29
Python
AlmaShooter, 2016-06-08 17:13:29

How to output data from XML and JSON array in Python?

I figured out how to send GET requests, the server responds and everything is fine with that. There is some code that will send a request and display the received response.

import requests

r = requests.get('https://privat24.privatbank.ua/p24/accountorder?oper=prp&PUREXML&apicour&country=ru')

print(r.text)

The response is output as it came from the server. How to extract data from it and display it in a convenient format? In this case, we get the current exchange rate and the output should be something like this:
Dollar exchange rate: 61.7235
Euro exchange rate: 70.0315

And preferably everything is the same only with JSON.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-06-08
@AlmaShooter

https://docs.python.org/2/library/xml.etree.elemen...
https://docs.python.org/2/library/xml.dom.minidom.html
lxml.de
We read, we do.
If something specific does not work out, then we already write here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question