blogger.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import requests
  6. from applications.utils import proxy
  7. from .use_js import call_js_function
  8. def get_toutiao_account_video_list(account_id: str, cookie: str, max_behot_time=0) -> dict:
  9. """
  10. get toutiao account video list
  11. :param account_id: toutiao account id
  12. :param cookie: cookie maybe expire not quite sure
  13. :param max_behot_time: max behot time
  14. :return: toutiao account video list
  15. """
  16. ms_token = 'mFs9gU4FJc23gFWPvBfQxFsBRrx1xBEJD_ZRTAolHfPrae84kTEBaHQR3s8ToiLX4-U9hgATTZ2cVHlSixmj5YCTOPoVM-43gOt3aVHkxfXHEuUtTJe-wUEs%3D'
  17. query_params = [
  18. 0,
  19. 1,
  20. 14,
  21. 'category=pc_user_hot&token={}&aid=24&app_name=toutiao_web&msToken={}'.format(account_id, ms_token),
  22. '',
  23. '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',
  24. ]
  25. a_bogus = call_js_function(query_params)
  26. 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}'
  27. headers = {
  28. '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',
  29. 'cookie': cookie
  30. }
  31. response = requests.get(url, headers=headers, proxies=proxy())
  32. return response.json()