wangkun há 2 anos atrás
pai
commit
90d226c0b5

+ 3 - 3
weixinzhishu/weixinzhishu_main/get_weixinzhishu.py

@@ -194,8 +194,8 @@ class Weixinzhishu:
         wechat_key = cls.get_wechat_key(log_type, crawler)
         search_key = wechat_key[0]
         openid = wechat_key[-1]
-        end_ymd = (date.today() + timedelta(days=-5)).strftime("%Y%m%d")
-        start_ymd = (date.today() + timedelta(days=-9)).strftime("%Y%m%d")
+        end_ymd = (date.today() + timedelta(days=0)).strftime("%Y%m%d")
+        start_ymd = (date.today() + timedelta(days=-7)).strftime("%Y%m%d")
         url = "https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex"
         payload = json.dumps({
             "openid": openid,
@@ -240,6 +240,6 @@ class Weixinzhishu:
 
 
 if __name__ == "__main__":
-    Weixinzhishu.get_score_test('weixin', 'weixinzhishu', 1 , "俞仁波")
+    Weixinzhishu.get_score_test('weixin', 'weixinzhishu', 1 , "天国")
 
     pass

+ 15 - 0
weixinzhishu/weixinzhishu_main/weixinzhishu_test.py

@@ -98,6 +98,18 @@ class Test:
                 cls.get_score_test(log_type, crawler)
             elif response.json()['code'] == -10002:
                 Common.logger(log_type, crawler).info("该词暂未收录")
+                # 写飞书
+                if word_list[i] in [x for y in Feishu.get_values_batch(log_type, crawler, "5011a2") for x in y]:
+                    Common.logger(log_type, crawler).info("该词已存在")
+                    break
+                Feishu.insert_columns(log_type, crawler, "5011a2", "ROWS", 1, 2)
+                time.sleep(0.5)
+                Feishu.update_values(log_type, crawler, "5011a2", "F2:Z2",
+                                     [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
+                                       word_list[i],
+                                       "",
+                                       "该词暂未收录"]])
+                Common.logger(log_type, crawler).info("写入飞书成功\n")
             elif response.json()['code'] != 0:
                 Common.logger(log_type, crawler).warning(f"{word_wechat_score_dict}")
             else:
@@ -110,6 +122,9 @@ class Test:
                     wechat_score_list.append(wechat_score_dict)
                     Common.logger(log_type, crawler).info(f"wechat_score_dict:{wechat_score_dict}")
                     # 写飞书
+                    if word_list[i] in [x for y in Feishu.get_values_batch(log_type, crawler, "5011a2") for x in y]:
+                        Common.logger(log_type, crawler).info("该词已存在")
+                        break
                     Feishu.insert_columns(log_type, crawler, "5011a2", "ROWS", 1, 2)
                     time.sleep(0.5)
                     Feishu.update_values(log_type, crawler, "5011a2", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),