fetch.py 268 B

123456789
  1. import aiohttp
  2. async def fetch(url):
  3. async with aiohttp.ClientSession() as session:
  4. async with session.get(url) as resp:
  5. try:
  6. data = await resp.json()
  7. except:
  8. data = await resp.text()
  9. return data