wangkun 2 年之前
父節點
當前提交
755785ea5d
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      weixinzhishu/weixinzhishu_key/search_key_mac.py

+ 4 - 3
weixinzhishu/weixinzhishu_key/search_key_mac.py

@@ -76,8 +76,8 @@ class SearchKey:
     # 获取微信指数小程序 search_key
     # 获取微信指数小程序 search_key
     @classmethod
     @classmethod
     def get_wechat_key(cls, log_type, crawler):
     def get_wechat_key(cls, log_type, crawler):
-        chlsfile_path = f"./{crawler}/{crawler}_chlsfiles/"
         while True:
         while True:
+            chlsfile_path = f"./{crawler}/{crawler}_chlsfiles/"
             if len(os.listdir(chlsfile_path)) == 0:
             if len(os.listdir(chlsfile_path)) == 0:
                 Common.logger(log_type, crawler).info("chlsfile文件夹空,等待 3 秒")
                 Common.logger(log_type, crawler).info("chlsfile文件夹空,等待 3 秒")
                 time.sleep(3)
                 time.sleep(3)
@@ -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/wxawebreport":
+                    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']
@@ -111,6 +111,7 @@ class SearchKey:
                             "openid": openid,
                             "openid": openid,
                         }
                         }
                         return wechat_key_dict
                         return wechat_key_dict
+                return "未找到wechat_key"
 
 
     # 删除 chlsfile 文件
     # 删除 chlsfile 文件
     @classmethod
     @classmethod