fetch.py 280 B

1234567891011
  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 Exception:
  8. data = await resp.text()
  9. return data