搜狗筛选.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : 搜狗筛选.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/9/11
  6. import requests
  7. from pprint import pprint
  8. cates = 'teleplay&film&cartoon&tvshow&documentary'.split('&')
  9. urls = [f'https://waptv.sogou.com/napi/video/classlist?abtest=0&iploc=CN1304&spver=&listTab={cate}&filter=&start=0&len=15&fr=filter' for cate in cates]
  10. print(urls)
  11. headers = {'user-agent':'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'}
  12. ft_dict = {}
  13. def getOne(url):
  14. r = requests.get(url, headers=headers)
  15. html = r.json()
  16. filters = html['listData']['list']['filter_list']
  17. cate_id = html['listData']['list']['entity']
  18. ft_dict[cate_id] = []
  19. for i in range(len(filters)):
  20. ft = filters[i]
  21. value = [{"n":"全部","v":""}]
  22. vl = [{"n":i,"v":i} for i in ft['option_list']]
  23. value.extend(vl)
  24. ft_dict[cate_id].append({
  25. 'key':ft['option_name'],
  26. 'name':ft['name'],
  27. 'value':value
  28. })
  29. return ft_dict
  30. # print(ft_dict)
  31. for url in urls:
  32. # print(getOne(urls[0]))
  33. # print(getOne(url))
  34. getOne(url)
  35. print(ft_dict)