Getter now returns JSON from Scryfall.

This commit is contained in:
Nanda Scott 2018-01-04 21:46:06 -05:00
parent 2e7d4af8e9
commit 48966b7b87
1 changed files with 18 additions and 0 deletions

18
getter.py Normal file
View File

@ -0,0 +1,18 @@
import asyncio, aiohttp
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)
async def getResponse(url, **kwargs):
async with session.get(url, **kwargs) as response:
return await response.json()
def formatUrl(endpoint):
return 'https://api.scryfall.com{}'.format(endpoint)
card = loop.run_until_complete(getResponse(url=formatUrl('/cards/named?'), params={'fuzzy':'black lotus'}))
print(card)
session.close()
loop.close()