sph_keyword.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import requests
  2. import json
  3. from common import Common, Feishu
  4. class KsKeyword:
  5. @classmethod
  6. def get_key_word(cls, keyword, task_mark, mark, channel_id, name, task):
  7. url = "http://8.217.190.241:8888/crawler/wei_xin/shi_pin_hao/keyword"
  8. list = []
  9. payload = json.dumps({
  10. "keyword": keyword,
  11. "sort": "不限",
  12. "cursor": ""
  13. })
  14. headers = {
  15. 'Content-Type': 'application/json'
  16. }
  17. try:
  18. response = requests.request("POST", url, headers=headers, data=payload)
  19. response = response.json()
  20. code = response['code']
  21. if code != 0:
  22. Feishu.finish_bot(f"shi_pin_hao/keyword {response['msg']}",
  23. "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb",
  24. "【视频号搜索接口使用提示】")
  25. Common.logger("sph-key-word").info(f"快手搜索词数据获取失败,{response['msg']}\n")
  26. return list
  27. data = response['data']['data']
  28. except Exception as exc:
  29. Common.logger("sph-key-word").info(f"视频号搜索词{keyword}获取失败{exc}\n")
  30. return list