12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- """
- @author: luojunhui
- """
- from __future__ import annotations
- import aiohttp
- from applications.utils import async_proxy
- from .use_js import call_js_function
- async def get_toutiao_account_info_list(
- account_id: str,
- cookie: str,
- media_type: str,
- max_behot_time=0,
- ) -> dict | None:
- """toutiao blogger"""
- ms_token = "mFs9gU4FJc23gFWPvBfQxFsBRrx1xBEJD_ZRTAolHfPrae84kTEBaHQR3s8ToiLX4-U9hgATTZ2cVHlSixmj5YCTOPoVM-43gOt3aVHkxfXHEuUtTJe-wUEs%3D"
- query_params = [
- 0,
- 1,
- 14,
- "category=pc_user_hot&token={}&aid=24&app_name=toutiao_web&msToken={}".format(
- account_id, ms_token
- ),
- "",
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
- ]
- a_bogus = call_js_function(query_params)
- headers = {
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
- "Cookie": cookie,
- "Content-Type": "application/json",
- }
- match media_type:
- case "article":
- url = f"https://www.toutiao.com/api/pc/list/user/feed?category=pc_profile_article&token={account_id}&max_behot_time={max_behot_time}&entrance_gid=&aid=24&app_name=toutiao_web&msToken={ms_token}&a_bogus={a_bogus}"
- case "video":
- url = f"https://www.toutiao.com/api/pc/list/user/feed?category=pc_profile_video&token={account_id}&max_behot_time={max_behot_time}&hot_video=0&entrance_gid=&aid=24&app_name=toutiao_web&msToken={ms_token}&a_bogus={a_bogus}"
- case _:
- return None
- proxy_url = async_proxy()["url"]
- proxy_auth = aiohttp.BasicAuth(async_proxy()["username"], async_proxy()["password"])
- async with aiohttp.ClientSession() as session:
- async with session.get(
- url, headers=headers, proxy=proxy_url, proxy_auth=proxy_auth
- ) as response:
- response.raise_for_status()
- return await response.json()
|