1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- """
- @author: luojunhui
- """
- import json
- import asyncio
- import aiohttp
- async def asyncPost(url, headers, payload):
- """
- :param url:
- :param headers:
- :param payload:
- :return:
- """
- retries = 3
- async with aiohttp.ClientSession() as session:
- for attempt in range(3):
- try:
- async with session.post(url, headers=headers, json=payload, timeout=10) as response:
- return await response.json()
- except asyncio.TimeoutError:
- if attempt < retries - 1:
- await asyncio.sleep(2) # 等待一段时间后重试
- else:
- raise
- async def getPQVideoDetail(video_id):
- """
- 获取票圈视频详情信息
- :return:
- """
- url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo"
- data = {
- "videoIdList": [video_id]
- }
- header = {
- "Content-Type": "application/json",
- }
- response = await asyncPost(url, header, data)
- return response
- #
- #
- # response = asyncio.run(getPQVideoDetail(24543579))
- #
- # print(json.dumps(response, ensure_ascii=False, indent=4))
|