Advertisement
ghost_net

Untitled

Sep 3rd, 2019
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. # This Python file uses the following encoding: utf-8
  2. import asyncio
  3.  
  4. import aiohttp
  5.  
  6. from typing import Dict
  7.  
  8.  
  9. class CryptoPrice:
  10. def __init__(self,session:aiohttp.ClientSession):
  11. self.link_main: str = "https://api.coingecko.com/api/v3/"
  12. self.obj: Dict = dict()
  13. self.coinlist: Dict = dict()
  14. self.session: aiohttp.ClientSession = session
  15.  
  16. def __len__(self):
  17. return len(self.obj)
  18.  
  19. async def CoinList(self):
  20. data = await self.GetJson(link=self.link_main + "coins/list")
  21. print(data)
  22. self.session.closed
  23.  
  24.  
  25. async def GetJson(self, link) -> Dict:
  26. async with self.session.get(url=link) as response:
  27. self.session.closed
  28.  
  29. return await response.json(content_type="application/json", encoding="utf-8")
  30.  
  31.  
  32.  
  33.  
  34.  
  35. p = CryptoPrice(aiohttp.ClientSession())
  36.  
  37. asyncio.run(p.CoinList())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement