Getter now returns JSON from Scryfall.
This commit is contained in:
		
							parent
							
								
									2e7d4af8e9
								
							
						
					
					
						commit
						48966b7b87
					
				| 
						 | 
					@ -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()
 | 
				
			||||||
		Loading…
	
		Reference in New Issue