Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This Python file uses the following encoding: utf-8
- import asyncio
- import aiohttp
- from typing import Dict
- class CryptoPrice:
- def __init__(self,session:aiohttp.ClientSession):
- self.link_main: str = "https://api.coingecko.com/api/v3/"
- self.obj: Dict = dict()
- self.coinlist: Dict = dict()
- self.session: aiohttp.ClientSession = session
- def __len__(self):
- return len(self.obj)
- async def CoinList(self):
- data = await self.GetJson(link=self.link_main + "coins/list")
- print(data)
- self.session.closed
- async def GetJson(self, link) -> Dict:
- async with self.session.get(url=link) as response:
- self.session.closed
- return await response.json(content_type="application/json", encoding="utf-8")
- p = CryptoPrice(aiohttp.ClientSession())
- asyncio.run(p.CoinList())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement