run_weixinzhishu_bot.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/4/21
  4. import datetime
  5. import os
  6. import sys
  7. import time
  8. sys.path.append(os.getcwd())
  9. from common.common import Common
  10. from common.feishu import Feishu
  11. class WeixinzhishuBot:
  12. @classmethod
  13. def search_key_bot(cls, log_type, crawler):
  14. Common.logger(log_type, crawler).info("开始检测微信指数 Search_Key 抓取状态")
  15. sheet = Feishu.get_values_batch(log_type, crawler, sheetid="sVL74k")
  16. if sheet is None:
  17. Common.logger(log_type, crawler).info(f"Search_Key_sheet:{sheet}\n")
  18. first_key_time_str = sheet[1][0]
  19. if first_key_time_str is None:
  20. if 14 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 40:
  21. Feishu.bot(log_type, crawler, "微信指数 Search_Key is None ~")
  22. time.sleep(3600*2)
  23. first_key_time_stamp = int(time.mktime(time.strptime(first_key_time_str, "%Y-%m-%d %H:%M:%S")))
  24. if int(time.time()) - first_key_time_stamp >= 60*3:
  25. if 14 >= datetime.datetime.now().hour >= 11 and datetime.datetime.now().minute >= 40:
  26. Feishu.bot(log_type, crawler, "微信指数 Search_Key 过期啦 ~")
  27. time.sleep(3600*2)
  28. else:
  29. Common.logger(log_type, crawler).info("微信指数 Search_Key 正常")
  30. Common.logger(log_type, crawler).info("微信指数 Search_Key 抓取状态检测结束\n")
  31. if __name__ == "__main__":
  32. WeixinzhishuBot.search_key_bot("bot", "weixinzhishu")
  33. pass