wangkun 2 vuotta sitten
vanhempi
commit
755785ea5d
1 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  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
     @classmethod
     def get_wechat_key(cls, log_type, crawler):
-        chlsfile_path = f"./{crawler}/{crawler}_chlsfiles/"
         while True:
+            chlsfile_path = f"./{crawler}/{crawler}_chlsfiles/"
             if len(os.listdir(chlsfile_path)) == 0:
                 Common.logger(log_type, crawler).info("chlsfile文件夹空,等待 3 秒")
                 time.sleep(3)
@@ -100,8 +100,8 @@ class SearchKey:
                 return "未找到wechat_key"
             else:
                 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}")
                         text = content['request']['body']['text']
                         search_key = json.loads(text)['search_key']
@@ -111,6 +111,7 @@ class SearchKey:
                             "openid": openid,
                         }
                         return wechat_key_dict
+                return "未找到wechat_key"
 
     # 删除 chlsfile 文件
     @classmethod