wangkun 2 роки тому
батько
коміт
98084e634e

BIN
weixinzhishu/.DS_Store


Різницю між файлами не показано, бо вона завелика
+ 0 - 0
weixinzhishu/weixinzhishu_chlsfiles/charles202303131913.txt


+ 20 - 9
weixinzhishu/weixinzhishu_key/search_key_mac.py

@@ -57,7 +57,7 @@ class SearchKey:
             Common.logger(log_type, crawler).info("点击微信指数小程序消息")
             for i in range(2):
                 weixinzhishu.clickMouseButtonLeft(weixinzhishu_coord)
-            time.sleep(1)
+            time.sleep(3)
 
             close_wechat = window.findFirstR(AXSubrole="AXCloseButton", AXRole="AXButton")
             close_wechat.Press()
@@ -101,8 +101,7 @@ 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/wxawebreport":
                             # print(f"content:{content}")
                             text = content['request']['body']['text']
                             search_key = json.loads(text)['search_key']
@@ -112,7 +111,17 @@ class SearchKey:
                                 "openid": openid,
                             }
                             return wechat_key_dict
-                    return "未找到wechat_key"
+                        elif content["host"] == "search.weixin.qq.com" and content["path"] == "/cgi-bin/wxaweb/wxindexgetusergroup":
+                            text = content['request']['body']['text']
+                            search_key = json.loads(text)['search_key']
+                            openid = json.loads(text)['openid']
+                            wechat_key_dict = {
+                                "search_key": search_key,
+                                "openid": openid,
+                            }
+                            return wechat_key_dict
+                        else:
+                            return "未找到wechat_key"
         except Exception as e:
             Common.logger(log_type, crawler).error(f"get_wechat_key:{e}\n")
 
@@ -152,8 +161,6 @@ class SearchKey:
         try:
             Common.logger(log_type, crawler).info(f"清空 chlsfiles 文件夹")
             cls.remove_chlsfile(log_type, crawler)
-            # Common.logger(log_type, crawler).info('启动微信指数小程序')
-            # cls.start_wechat(log_type, crawler)
             Common.logger(log_type, crawler).info('获取 wechat_key')
             while True:
                 cls.start_wechat(log_type, crawler)
@@ -179,14 +186,18 @@ class SearchKey:
     @classmethod
     def main(cls, log_type, crawler):
         while True:
-            cls.write_wechat_key(log_type, crawler)
-            Common.logger('searchkey', 'weixinzhishu').info('休眠10秒\n')
-            time.sleep(10)
+            try:
+                cls.write_wechat_key(log_type, crawler)
+                Common.logger('searchkey', 'weixinzhishu').info('休眠10秒\n')
+                time.sleep(10)
+            except Exception as e:
+                Common.logger(log_type, crawler).error(f"{e}\n")
 
 
 if __name__ == "__main__":
     # SearchKey.start_wechat("search", "weixinzhishu")
     # SearchKey.del_wechat_key("search", "weixinzhishu")
     # SearchKey.write_wechat_key("search", "weixinzhishu")
+    # print(SearchKey.get_wechat_key("search", "weixinzhishu"))
     SearchKey.main("search", "weixinzhishu")
     pass

Деякі файли не було показано, через те що забагато файлів було змінено