1234567891011121314151617181920212223242526272829 |
- # -*- coding: utf-8 -*-
- # @Time : 2023/7/20 16:29
- # @Author : XuJiakai
- # @File : http_api
- # @Software: PyCharm
- import json
- import aiohttp
- from data_clean.exception.fetch_exception import FetchException
- async def get(url: str):
- async with aiohttp.ClientSession() as session:
- async with session.get(url) as response:
- text = await response.text()
- if response.status != 200:
- raise FetchException(response.status, text)
- return text
- pass
- async def get_json(url: str):
- text = await get(url)
- return json.loads(text)
- if __name__ == '__main__':
- pass
|