-2
I’m doing an algorithm on Python that makes a get in a url to dollar quotation, but the return of that get has a lot of unnecessary information I would like to know how to filter this data follows below the code and the response of the request.
import requests
import json
requisicao = requests.get('https://economia.awesomeapi.com.br/all/USD')
dicionario = json.loads(requisicao.text)
print(requisicao.content)
RESPONSE TO THE REQUEST
b'{"USD":{"code":"USD","codein":"BRL","name":"D\xc3\xb3lar Comercial","high":"5.3944","low":"5.3045","varBid":"0.0005","pctChange":"0.01","bid":"5.3237","ask":"5.3247","timestamp":"1606339799","create_date":"2020-11-25 19:00:01"}}'
How do I implement this in the code?
– Erico Peixoto
It depends on what information you want to extract. The example I gave can be used for any key in your dictionary. The return of your request is a json with only the dollar, if it returns other currencies you could filter for example:
dicionario['BRL']['low']
– lmonferrari
Thanks to be able to complete the algorithm, thanks bro
– Erico Peixoto