diff --git a/userge/utils/helper/__init__.py b/userge/utils/helper/__init__.py new file mode 100644 index 000000000..055e9e08a --- /dev/null +++ b/userge/utils/helper/__init__.py @@ -0,0 +1 @@ +from .aiohttp_helper import AioHttp \ No newline at end of file diff --git a/userge/utils/helper/aiohttp_helper.py b/userge/utils/helper/aiohttp_helper.py new file mode 100644 index 000000000..4501de9e3 --- /dev/null +++ b/userge/utils/helper/aiohttp_helper.py @@ -0,0 +1,21 @@ +import aiohttp + + +class AioHttp: + @staticmethod + async def get_json(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.json() + + @staticmethod + async def get_text(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.text() + + @staticmethod + async def get_raw(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.read() \ No newline at end of file