wangkun преди 2 години
родител
ревизия
14204b3a23
променени са 4 файла, в които са добавени 80 реда и са изтрити 79 реда
  1. 37 60
      README.md
  2. 2 2
      bot.sh
  3. 11 1
      main/feishu_lib.py
  4. 30 16
      main/run_bot.py

+ 37 - 60
README.md

@@ -1,61 +1,38 @@
 # 爬虫监控
-https://git.yishihui.com/Server/crawler_bot.git
-
-#### 增加监控渠道
-1. feishu_lib:
-   1. 增加爬虫表链接
-   2. 增加飞书路径token: feishu_lib.spreadsheettoken
-   3. 增加机器人消息: feishu_lib.bot
-2. run_bot:
-   1. 增加爬虫最新数据抓取时间: run_bot.get_first_time
-   2. 增加触发机器人报警机制: run_bot.robot_download_sheet
-   3. 主函数增加渠道: run_bot.main
-
-#### 软件架构
-1. python==3.10 
-2. loguru==0.6.0 
-3. oss2==2.15.0 
-4. requests==2.27.1 
-5. urllib3==1.26.9
-
-
-#### 使用说明
-1. cd ./crawler_bot 
-2. sh bot.sh
-
-
-#### 需求
-2022/12/06
-1. 增加报警:好看视频 PC 版
-
-2022/11/30
-1. 增加报警: 宗教公众号
-
-2022/11/21
-1. 增加报警: 祝福猫视频
-
-2022/11/09
-1. 增加报警: 岁岁年年迎福气小程序
-
-2022/11/07
-1. 增加: 吉祥幸福小程序报警
-2. 增加: 众妙音信小程序报警
-
-2022/11/03
-1. 增加:知乎 PC 端爬虫报警
-
-2022/10/20
-1. 增加: 西瓜视频报警
-
-2022/10/19
-1. 小年糕3种爬取方式分别报警
-
-2022/9/13
-1. 增加监控渠道: 视频号
-
-2022/8/19
-1. 增加监控渠道: 公众号 / 微视
-
-2022/8/10
-1. 每天检查一次已下载表 
-2. 已下载表的最新一条数据抓取时间,距当前时间超过 24 小时,则触发机器人报警,发送飞书报警消息
+* [git](https://git.yishihui.com/Server/crawler_bot.git)
+
+## 增加监控渠道
+* feishu_lib:
+  * 增加爬虫表链接
+  * 增加飞书路径token: feishu_lib.spreadsheettoken
+  * 增加机器人消息: feishu_lib.bot
+* run_bot:
+  * 增加爬虫最新数据抓取时间: run_bot.get_first_time
+  * 增加触发机器人报警机制: run_bot.robot_download_sheet
+* run_bot.main
+  * 主函数增加相应渠道
+
+## 软件架构
+* python==3.10 
+* loguru==0.6.0 
+* oss2==2.15.0 
+* requests==2.27.1 
+* urllib3==1.26.9
+
+## 使用说明
+* cd ./crawler_bot 
+* sh bot.sh
+
+## 更新记录
+* 2022/01/11 增加报警: 刚刚都传
+* 2022/12/06 增加报警: 好看视频 PC 版
+* 2022/11/30 增加报警: 宗教公众号
+* 2022/11/21 增加报警: 祝福猫视频
+* 2022/11/09 增加报警: 岁岁年年迎福气小程序
+* 2022/11/07 增加报警: 吉祥幸福小程序;众妙音信小程序
+* 2022/11/03 增加报警: 知乎 PC 版
+* 2022/10/20 增加报警: 西瓜视频 PC 版
+* 2022/10/19 增加报警: 小年糕_上升榜;小年糕_定向榜;小年糕_播放量榜
+* 2022/09/13 增加报警: 微信视频号
+* 2022/08/19 增加报警: 公众号 / 微视
+* 2022/08/10 每天 10 点检查一次已下载表; 已下载表的最新一条数据抓取时间,距当前时间超过 24 小时,则触发机器人报警,发送飞书报警消息

+ 2 - 2
bot.sh

@@ -1,8 +1,8 @@
 #!/bin/bash
+
 echo "开始"
+
 echo "$(date "+%Y-%m-%d %H:%M:%S") 正在杀进程..."
-# shellcheck disable=SC2009
-# ps aux | grep run_bot
 ps aux | grep run_bot.py | grep -v grep | awk '{print $2}' | xargs kill -9
 echo "$(date "+%Y-%m-%d %H:%M:%S") 进程已杀死!"
 

+ 11 - 1
main/feishu_lib.py

@@ -52,6 +52,8 @@ class Feishu:
     crawler_kandaojiushifuqi = 'https://w42nne6hzg.feishu.cn/sheets/shtcnEokBkIjOUPAk8vbbPKnXgb'
     # 胜胜影音
     crawler_shengshengyingyin = 'https://w42nne6hzg.feishu.cn/sheets/shtcnz1ymxHL1u8WHblfqfys7qe'
+    # 刚刚都传
+    crawler_ganggangdouchuan = 'https://w42nne6hzg.feishu.cn/sheets/shtcnTuJgeZU2bc7VaesAqk3QJx'
 
     # 飞书路径token
     @classmethod
@@ -99,6 +101,8 @@ class Feishu:
             return 'shtcnEokBkIjOUPAk8vbbPKnXgb'
         elif crawler == 'ssyy':
             return 'shtcnz1ymxHL1u8WHblfqfys7qe'
+        elif crawler == 'ggdc':
+            return 'shtcnTuJgeZU2bc7VaesAqk3QJx'
 
     # 获取飞书api token
     @classmethod
@@ -470,6 +474,12 @@ class Feishu:
                 users = "\n<at id=" + str(cls.get_userid(log_type, "wangkun")) + "></at> <at id=" + str(
                     cls.get_userid(log_type, "gaonannan")) + "></at>\n"
 
+            elif crawler == "ggdc":
+                content = "刚刚都传爬虫表"
+                sheet_url = "https://w42nne6hzg.feishu.cn/sheets/shtcnTuJgeZU2bc7VaesAqk3QJx"
+                users = "\n<at id=" + str(cls.get_userid(log_type, "wangkun")) + "></at> <at id=" + str(
+                    cls.get_userid(log_type, "gaonannan")) + "></at>\n"
+
             elif crawler == "bszf":
                 content = "本山祝福爬虫表"
                 sheet_url = "https://w42nne6hzg.feishu.cn/sheets/shtcnGh2rrsPYM4iVNEBO7OqWrb"
@@ -599,7 +609,7 @@ class Feishu:
 
 
 if __name__ == "__main__":
-    Feishu.bot("bot", "ssyy", "别紧张,还是我,测试一下")
+    Feishu.bot("bot", "ggdc", "别紧张,还是我,测试一下")
     # print(Feishu.get_userid("shipinhao", "lijinchao"))
     
     pass

+ 30 - 16
main/run_bot.py

@@ -72,6 +72,12 @@ class Bot:
                 first_download_time = sheet[1][5]
                 first_download_time = int(time.mktime(time.strptime(first_download_time, "%Y/%m/%d %H:%M:%S")))
 
+            elif crawler == 'ggdc':
+                sheet = Feishu.get_values_batch(log_type, 'ggdc', '070a67')
+                # 已下载表,最新一条视频抓取时间
+                first_download_time = sheet[1][5]
+                first_download_time = int(time.mktime(time.strptime(first_download_time, "%Y/%m/%d %H:%M:%S")))
+
             elif crawler == 'jxxf':
                 sheet = Feishu.get_values_batch(log_type, "jxxf", "d9e9b1")
                 # 已下载表,最新一条视频抓取时间
@@ -238,6 +244,12 @@ class Bot:
                 Feishu.bot(log_type, crawler, "胜胜影音_已下载表,超过24小时没有新视频入库了😤")
                 Common.logger(log_type).warning("胜胜影音_已下载表,超过24小时没有新视频入库了😤\n")
 
+            # 刚刚都传
+            elif crawler == "ggdc" and (
+                    int(time.time()) - cls.get_first_time(log_type, crawler) > int(duration)):
+                Feishu.bot(log_type, crawler, "刚刚都传_已下载表,超过24小时没有新视频入库了😤")
+                Common.logger(log_type).warning("刚刚都传_已下载表,超过24小时没有新视频入库了😤\n")
+
             # 吉祥幸福
             elif crawler == "jxxf" and (
                     int(time.time()) - cls.get_first_time(log_type, crawler) > int(duration)):
@@ -340,10 +352,6 @@ class Bot:
                 Bot.robot_download_sheet("bot", "xiaoniangao_person", duration)
                 Bot.robot_download_sheet("bot", "xiaoniangao_play", duration)
 
-                # Common.logger("bot").info("监控西瓜视频已下载表")
-                # Bot.robot_download_sheet("bot", "xigua_video", duration)
-                # Bot.robot_download_sheet("bot", "xigua_little_video", duration)
-
                 Common.logger('bot').info('监控知乎已下载表')
                 Bot.robot_download_sheet("bot", "zhihu_hot", duration)
                 Bot.robot_download_sheet("bot", "zhihu_follow", duration)
@@ -352,18 +360,9 @@ class Bot:
                 Bot.robot_download_sheet("bot", "haokan_hot", duration)
                 Bot.robot_download_sheet("bot", "haokan_channel", duration)
 
-                # Common.logger("bot").info("监控胜胜影音已下载表")
-                # Bot.robot_download_sheet("bot", "ssyy", duration)
-
                 Common.logger("bot").info("监控吉祥幸福已下载表")
                 Bot.robot_download_sheet("bot", "jxxf", duration)
 
-                # Common.logger("bot").info("监控众妙音信已下载表")
-                # Bot.robot_download_sheet("bot", "zmyx", duration)
-
-                # Common.logger("bot").info("监控祝福猫已下载表")
-                # Bot.robot_download_sheet("bot", "zhufumao", duration)
-
                 Common.logger("bot").info("监控岁岁年年迎福气已下载表")
                 Bot.robot_download_sheet("bot", "ssnnyfq", duration)
 
@@ -381,12 +380,27 @@ class Bot:
                 Bot.robot_download_sheet("bot", "weishi", duration)
 
                 Common.logger("bot").info("监控视频号已下载表")
-                # Bot.robot_download_sheet("bot", "shipinhao_recommend", duration)
                 Bot.robot_download_sheet("bot", "shipinhao_follow", duration)
 
                 Common.logger("bot").info("监控宗教公众号已下载表")
                 Bot.robot_download_sheet("bot", "zongjiao", duration)
 
+                Common.logger("bot").info("刚刚都传已下载表")
+                Bot.robot_download_sheet("bot", "ggdc", duration)
+
+                # Common.logger("bot").info("监控众妙音信已下载表")
+                # Bot.robot_download_sheet("bot", "zmyx", duration)
+
+                # Common.logger("bot").info("监控祝福猫已下载表")
+                # Bot.robot_download_sheet("bot", "zhufumao", duration)
+
+                # Common.logger("bot").info("监控西瓜视频已下载表")
+                # Bot.robot_download_sheet("bot", "xigua_video", duration)
+                # Bot.robot_download_sheet("bot", "xigua_little_video", duration)
+
+                # Common.logger("bot").info("监控胜胜影音已下载表")
+                # Bot.robot_download_sheet("bot", "ssyy", duration)
+
                 # Common.logger("bot").info("监控公众号已下载表")
                 # Bot.robot_download_sheet("bot", "gzh", duration)
 
@@ -405,7 +419,7 @@ class Bot:
 
 if __name__ == "__main__":
 
-    # Bot.robot_download_sheet("bot", "ssyy", 1)
-    Bot.main()
+    Bot.robot_download_sheet("bot", "ggdc", 1)
+    # Bot.main()
 
     pass