Browse Source

add weixinzhishu: search_key

wangkun 2 years ago
parent
commit
e3cec51a3b

+ 1 - 1
weixinzhishu/weixinzhishu_main/search_key.py

@@ -96,7 +96,7 @@ class Searchkey:
                 else:
                     for content in contents:
                         if content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
-                            print(f"content:{content}")
+                            # print(f"content:{content}")
                             text = content['request']['body']['text']
                             search_key = json.loads(text)['search_key']
                             openid = json.loads(text)['openid']

+ 28 - 3
weixinzhishu/weixinzhishu_main/weixinzhishu.py

@@ -1,17 +1,42 @@
 # -*- coding: utf-8 -*-
 # @Author: wangkun
 # @Time: 2023/2/10
+from datetime import date, timedelta
+
 import requests
 import json
 
+from common.feishu import Feishu
+
 
 class Weixinzhishu:
+    @classmethod
+    def search_word(cls):
+        return ["消息", "彻底", "现在", "真是", "突然", "消失", "太好了", "心声"]
+
+    @classmethod
+    def wechat_key(cls, log_type, crawler):
+        sheet = Feishu.get_values_batch(log_type, crawler, 'sVL74k')
+        for i in range(len(sheet)):
+            search_key = sheet[1][1]
+            openid = sheet[1][2]
+            return search_key, openid
+
     @classmethod
     def weixinzhishu(cls, log_type, crawler, query):
+        wechat_key = cls.wechat_key(log_type, crawler)
+        search_key = wechat_key[0]
+        openid = wechat_key[-1]
+        start_ymd = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d").replace("-", "")
+        end_ymd = (date.today() + timedelta(days=-8)).strftime("%Y-%m-%d").replace("-", "")
+        print(f"search_key:{search_key}")
+        print(f"openid:{openid}")
+        print(f"start_ymd:{start_ymd}")
+        print(f"start_ymd:{end_ymd}")
         url = "https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex"
         payload = json.dumps({
-            "openid": "ov4ns0KAQ7u9QlaFViTsUk7aTwU8",
-            "search_key": "1676287183675843_2172943316",
+            "openid": openid,
+            "search_key": search_key,
             "cgi_name": "GetDefaultIndex",
             "start_ymd": "20230206",
             "end_ymd": "20230210",
@@ -30,4 +55,4 @@ class Weixinzhishu:
 
 
 if __name__ == "__main__":
-    Weixinzhishu.weixinzhishu('weixin', 'weixinzhishu', '狂飙')
+    Weixinzhishu.weixinzhishu('weixin', 'weixinzhishu', '狂飙')