wangkun há 2 anos atrás
pai
commit
074ac5b2fd

+ 6 - 6
weixinzhishu/weixinzhishu_key/search_key_mac.py

@@ -100,8 +100,8 @@ class SearchKey:
                 return "未找到wechat_key"
                 return "未找到wechat_key"
             else:
             else:
                 for content in contents:
                 for content in contents:
-                    if content["host"] == "search.weixin.qq.com" and content[
-                        "path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
+                    # if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
+                    if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxawebreport":
                         # print(f"content:{content}")
                         # print(f"content:{content}")
                         text = content['request']['body']['text']
                         text = content['request']['body']['text']
                         search_key = json.loads(text)['search_key']
                         search_key = json.loads(text)['search_key']
@@ -130,7 +130,7 @@ class SearchKey:
     def del_wechat_key(cls, log_type, crawler):
     def del_wechat_key(cls, log_type, crawler):
         try:
         try:
             while True:
             while True:
-                sheet = Feishu.get_values_batch(log_type, crawler, 'pIW4Bq')
+                sheet = Feishu.get_values_batch(log_type, crawler, 'sVL74k')
                 if sheet is None:
                 if sheet is None:
                     Common.logger(log_type, crawler).info(f"wechat_key_sheet:{sheet}, 1秒后重新获取")
                     Common.logger(log_type, crawler).info(f"wechat_key_sheet:{sheet}, 1秒后重新获取")
                     time.sleep(1)
                     time.sleep(1)
@@ -138,7 +138,7 @@ class SearchKey:
                 if len(sheet) <= 51:
                 if len(sheet) <= 51:
                     return
                     return
                 else:
                 else:
-                    Feishu.dimension_range(log_type, crawler, 'pIW4Bq', 'ROWS', 52, 52)
+                    Feishu.dimension_range(log_type, crawler, 'sVL74k', 'ROWS', 52, 52)
         except Exception as e:
         except Exception as e:
             Common.logger(log_type, crawler).error(f"del_wechat_key异常:{e}\n")
             Common.logger(log_type, crawler).error(f"del_wechat_key异常:{e}\n")
 
 
@@ -159,11 +159,11 @@ class SearchKey:
                 continue
                 continue
             for k, v in wechat_key_dict.items():
             for k, v in wechat_key_dict.items():
                 Common.logger(log_type, crawler).info(f"{k}:{v}")
                 Common.logger(log_type, crawler).info(f"{k}:{v}")
-            Feishu.insert_columns(log_type, crawler, 'pIW4Bq', 'ROWS', 1, 2)
+            Feishu.insert_columns(log_type, crawler, 'sVL74k', 'ROWS', 1, 2)
             time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time())))
             time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time())))
             values = [[time_str, wechat_key_dict['search_key'], wechat_key_dict['openid']]]
             values = [[time_str, wechat_key_dict['search_key'], wechat_key_dict['openid']]]
             time.sleep(1)
             time.sleep(1)
-            Feishu.update_values(log_type, crawler, 'pIW4Bq', 'A2:Z2', values)
+            Feishu.update_values(log_type, crawler, 'sVL74k', 'A2:Z2', values)
             cls.del_wechat_key(log_type, crawler)
             cls.del_wechat_key(log_type, crawler)
             Common.logger(log_type, crawler).info("wechat_key写入飞书成功")
             Common.logger(log_type, crawler).info("wechat_key写入飞书成功")
             Common.del_logs(log_type, crawler)
             Common.del_logs(log_type, crawler)

+ 28 - 0
weixinzhishu/weixinzhishu_main/weixinzhishu_del_null.py

@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2023/3/13
+from common.feishu import Feishu
+
+
+class Delete:
+    @classmethod
+    def del_null(cls, log_type, crawler, sheetid):
+        while True:
+            sheet = Feishu.get_values_batch(log_type, crawler, sheetid)
+            if sheet is None:
+                continue
+            for i in range(1, len(sheet)):
+                if i == len(sheet):
+                    print("删除完毕")
+                    return
+                print(f"正在判断{i+1}行")
+                get_time = sheet[i][5]
+                title = sheet[i][6]
+                if get_time is None or title is None:
+                    Feishu.dimension_range(log_type, crawler, sheetid, "ROWS", i+1, i+1)
+                    print(f"第{i+1}行:空行,已删除")
+                    break
+
+
+if __name__ == "__main__":
+    Delete.del_null("del", "weixinzhishu", "UQCMHR")