add currencies code

This commit is contained in:
Aleksei Krugliak 2022-04-24 00:04:48 +04:00
parent d82a7e0fc1
commit fc133973f1
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
from aiogram import types
from loader import dp
import json
@dp.message_handler(commands="currencies")
async def get_currencies(message: types.Message):
import requests
import datetime
url = 'https://nbg.gov.ge/gw/api/ct/monetarypolicy/currencies/en/json/'
date = datetime.date.today().isoformat()
payload = {'currencies': ['USD', 'EUR'], 'date': date}
r = requests.get(url, params=payload)
print(r.text)
usd = json.loads(r.text)
for elem in usd:
# print(elem['currencies'])
for each in elem['currencies']:
# print(each)
# print(each['code'] + " " + each['rateFormated'])
await message.answer(each['code'] + " " + each['rateFormated'])
# print(r.status_code)