From 48966b7b87c6a32bd704a95ef6175130cde5c524 Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Thu, 4 Jan 2018 21:46:06 -0500 Subject: [PATCH] Getter now returns JSON from Scryfall. --- getter.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 getter.py diff --git a/getter.py b/getter.py new file mode 100644 index 0000000..8b3cf66 --- /dev/null +++ b/getter.py @@ -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()