wangkun 2 jaren geleden
bovenliggende
commit
f0adc4ebf6

BIN
.DS_Store


BIN
weixinzhishu/.DS_Store


+ 31 - 4
weixinzhishu/weixinzhishu_main/search_key_mac.py

@@ -10,14 +10,41 @@ class SearchKey:
     def start_wechat(cls):
         # 启动应用并获取应用信息
         bundle_id = "com.tencent.xinWeChat"
+        print("启动微信")
         atomac.launchAppByBundleId(bundle_id)
         automator = atomac.getAppRefByBundleId(bundle_id)
-        time.sleep(3)
+        time.sleep(1)
         # 获取当前应用window
         window = automator.windows()[0]
-        print(f"当前应用window:{window}")
-        msg_box = window.findFirstR(AXRole="AXCell", AXIdentifier="MMChatsTableCellView_0")
-        print(msg_box.getAttributes())
+        print(f"当前应用window:{window.AXTitle}")
+        # 查找聊天按钮
+        print("查找聊天按钮")
+        chat_btn = window.findFirstR(AXHelp="微信", AXRole="AXRadioButton")
+        # print(chat_btn.getAttributes())
+        # 点击聊天按钮,展开聊天列表
+        print("点击聊天按钮")
+        chat_btn.Press()
+
+        # # 查找文件传输助手
+        # print("查找文件传输助手")
+        # chat_help = window.findFirstR(AXRole="AXCell")
+        # print(f"文件传输助手:{chat_help}")
+        # print("点击文件传输助手")
+        # chat_help_position = chat_help.AXSize
+        # chat_help.clickMouseButtonLeft(chat_help_position)
+
+        print("查找微信指数小程序消息")
+        # chat_msg = window.findFirstR(AXIdentifier="MMNormalAppBrandMessageCellView", AXRole="AXUnknown")
+        chat_msg = window.findFirstR(AXValue="小程序", AXRole="AXStaticText")
+        print(f"微信指数小程序消息:{chat_msg}")
+        print("点击微信指数小程序消息")
+        chat_msg_position = chat_msg.AXSize
+        print(chat_msg_position)
+        chat_msg.clickMouseButtonLeft(chat_msg_position)
+        # chat_msg_position.Press()
+        time.sleep(3)
+
+
 
 
 

+ 22 - 19
weixinzhishu/weixinzhishu_main/weixinzhishu_inner_long.py

@@ -10,6 +10,7 @@ import requests
 sys.path.append(os.getcwd())
 from common.common import Common
 from common.feishu import Feishu
+proxies = {"http": None, "https": None}
 
 
 class Test:
@@ -42,19 +43,19 @@ class Test:
     def get_words(cls, log_type, crawler):
         try:
             while True:
-                sheet = Feishu.get_values_batch(log_type, crawler, 'VoqDih')
+                sheet = Feishu.get_values_batch(log_type, crawler, 'X6K0vN')
                 if sheet is None:
                     Common.logger(log_type, crawler).warning(f"获取热词sheet:{sheet} ,10秒钟后重试")
                     time.sleep(10)
                 else:
                     break
             word_list = []
-            for x in sheet:
-                for y in x:
-                    if y is None:
-                        pass
-                    else:
-                        word_list.append(y)
+            for i in range(len(sheet)):
+                word_dict = {
+                    "title": sheet[i][0],
+                    "word": sheet[i][1]
+                }
+                word_list.append(word_dict)
             return word_list
         except Exception as e:
             Common.logger(log_type, crawler).error(f"get_words:{e}\n")
@@ -67,7 +68,7 @@ class Test:
 
         word_list = cls.get_words(log_type, crawler)
         for i in range(len(word_list)):
-            Common.logger(log_type, crawler).info(f"热词: {word_list[i]}")
+            Common.logger(log_type, crawler).info(f"热词: {word_list[i]['word']}")
             while True:
                 wechat_key = cls.get_wechat_key(log_type, crawler)
                 if wechat_key is None:
@@ -85,7 +86,7 @@ class Test:
                     "cgi_name": "GetDefaultIndex",
                     "start_ymd": start_ymd,
                     "end_ymd": end_ymd,
-                    "query": word_list[i]
+                    "query": word_list[i]['word']
                 })
                 headers = {
                     'Host': 'search.weixin.qq.com',
@@ -93,7 +94,7 @@ class Test:
                     'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x1800202a) NetType/WIFI Language/zh_CN',
                     'Referer': 'https://servicewechat.com/wxc026e7662ec26a3a/42/page-frame.html'
                 }
-                response = requests.request("POST", url, headers=headers, data=payload)
+                response = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
                 if response.json()['code'] == -10000:
                     Common.logger(log_type, crawler).info(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} response:{response.json()['msg']} 休眠 10 秒,重新获取")
                     time.sleep(10)
@@ -102,20 +103,21 @@ class Test:
                 wechat_score_list = []
                 word_wechat_score_dict = {
                     "id": i+1,
-                    "word": word_list[i],
+                    "word": word_list[i]['word'],
                     "wechatScores": wechat_score_list,
                 }
                 if 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, "zBXOUq") for x in y]:
+                    if word_list[i]['word'] in [x for y in Feishu.get_values_batch(log_type, crawler, "JpgyAv") for x in y]:
                         Common.logger(log_type, crawler).info("该词已存在")
                         continue
-                    Feishu.insert_columns(log_type, crawler, "zBXOUq", "ROWS", 1, 2)
+                    Feishu.insert_columns(log_type, crawler, "JpgyAv", "ROWS", 1, 2)
                     time.sleep(0.5)
-                    Feishu.update_values(log_type, crawler, "zBXOUq", "F2:Z2",
+                    Feishu.update_values(log_type, crawler, "JpgyAv", "F2:Z2",
                                          [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
-                                           word_list[i],
+                                           word_list[i]['title'],
+                                           word_list[i]['word'],
                                            "",
                                            "该词暂未收录"]])
                     Common.logger(log_type, crawler).info("写入飞书成功\n")
@@ -125,17 +127,18 @@ class Test:
                 else:
                     time_index = response.json()['content']['resp_list'][0]['indexes'][0]['time_indexes']
                     for x in range(len(time_index)):
-                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]}")
+                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]['word']}")
                         score_time = time_index[x]['time']
                         score_time_str = f"{str(score_time)[:4]}-{str(score_time)[4:6]}-{str(score_time)[6:]}"
                         score = time_index[x]['score']
                         wechat_score_dict = {"score": score, "scoreDate": score_time_str}
                         wechat_score_list.append(wechat_score_dict)
                         Common.logger(log_type, crawler).info(f"wechat_score_dict:{wechat_score_dict}")
-                        Feishu.insert_columns(log_type, crawler, "zBXOUq", "ROWS", 1, 2)
+                        Feishu.insert_columns(log_type, crawler, "JpgyAv", "ROWS", 1, 2)
                         time.sleep(1)
-                        Feishu.update_values(log_type, crawler, "zBXOUq", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
-                                                                               word_list[i],
+                        Feishu.update_values(log_type, crawler, "JpgyAv", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
+                                                                               word_list[i]['title'],
+                                                                               word_list[i]['word'],
                                                                                score_time_str,
                                                                                score]])
                         Common.logger(log_type, crawler).info("写入飞书成功\n")

+ 24 - 21
weixinzhishu/weixinzhishu_main/weixinzhishu_inner_sort.py

@@ -10,6 +10,7 @@ import requests
 sys.path.append(os.getcwd())
 from common.common import Common
 from common.feishu import Feishu
+proxies = {"http": None, "https": None}
 
 
 class Test:
@@ -42,19 +43,19 @@ class Test:
     def get_words(cls, log_type, crawler):
         try:
             while True:
-                sheet = Feishu.get_values_batch(log_type, crawler, 'SuhTA6')
+                sheet = Feishu.get_values_batch(log_type, crawler, 'D9IqTp')
                 if sheet is None:
                     Common.logger(log_type, crawler).warning(f"获取热词sheet:{sheet} ,10秒钟后重试")
                     time.sleep(10)
                 else:
                     break
             word_list = []
-            for x in sheet:
-                for y in x:
-                    if y is None:
-                        pass
-                    else:
-                        word_list.append(y)
+            for i in range(len(sheet)):
+                word_dict = {
+                    "title": sheet[i][0],
+                    "word": sheet[i][1]
+                }
+                word_list.append(word_dict)
             return word_list
         except Exception as e:
             Common.logger(log_type, crawler).error(f"get_words:{e}\n")
@@ -67,7 +68,7 @@ class Test:
 
         word_list = cls.get_words(log_type, crawler)
         for i in range(len(word_list)):
-            Common.logger(log_type, crawler).info(f"热词: {word_list[i]}")
+            Common.logger(log_type, crawler).info(f"热词: {word_list[i]['word']}")
             while True:
                 wechat_key = cls.get_wechat_key(log_type, crawler)
                 if wechat_key is None:
@@ -85,7 +86,7 @@ class Test:
                     "cgi_name": "GetDefaultIndex",
                     "start_ymd": start_ymd,
                     "end_ymd": end_ymd,
-                    "query": word_list[i]
+                    "query": word_list[i]['word']
                 })
                 headers = {
                     'Host': 'search.weixin.qq.com',
@@ -93,7 +94,7 @@ class Test:
                     'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x1800202a) NetType/WIFI Language/zh_CN',
                     'Referer': 'https://servicewechat.com/wxc026e7662ec26a3a/42/page-frame.html'
                 }
-                response = requests.request("POST", url, headers=headers, data=payload)
+                response = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
                 if response.json()['code'] == -10000:
                     Common.logger(log_type, crawler).info(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} response:{response.json()['msg']} 休眠 10 秒,重新获取")
                     time.sleep(10)
@@ -102,20 +103,21 @@ class Test:
                 wechat_score_list = []
                 word_wechat_score_dict = {
                     "id": i+1,
-                    "word": word_list[i],
+                    "word": word_list[i]['word'],
                     "wechatScores": wechat_score_list,
                 }
                 if 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, "2fP99U") for x in y]:
+                    if word_list[i]['word'] in [x for y in Feishu.get_values_batch(log_type, crawler, "DrZHpa") for x in y]:
                         Common.logger(log_type, crawler).info("该词已存在")
                         continue
-                    Feishu.insert_columns(log_type, crawler, "2fP99U", "ROWS", 1, 2)
+                    Feishu.insert_columns(log_type, crawler, "DrZHpa", "ROWS", 1, 2)
                     time.sleep(0.5)
-                    Feishu.update_values(log_type, crawler, "2fP99U", "F2:Z2",
+                    Feishu.update_values(log_type, crawler, "DrZHpa", "F2:Z2",
                                          [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
-                                           word_list[i],
+                                           word_list[i]['title'],
+                                           word_list[i]['word'],
                                            "",
                                            "该词暂未收录"]])
                     Common.logger(log_type, crawler).info("写入飞书成功\n")
@@ -125,19 +127,20 @@ class Test:
                 else:
                     time_index = response.json()['content']['resp_list'][0]['indexes'][0]['time_indexes']
                     for x in range(len(time_index)):
-                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]}")
+                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]['word']}")
                         score_time = time_index[x]['time']
                         score_time_str = f"{str(score_time)[:4]}-{str(score_time)[4:6]}-{str(score_time)[6:]}"
                         score = time_index[x]['score']
                         wechat_score_dict = {"score": score, "scoreDate": score_time_str}
                         wechat_score_list.append(wechat_score_dict)
                         Common.logger(log_type, crawler).info(f"wechat_score_dict:{wechat_score_dict}")
-                        Feishu.insert_columns(log_type, crawler, "2fP99U", "ROWS", 1, 2)
+                        Feishu.insert_columns(log_type, crawler, "DrZHpa", "ROWS", 1, 2)
                         time.sleep(1)
-                        Feishu.update_values(log_type, crawler, "2fP99U", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
-                                                                               word_list[i],
-                                                                               score_time_str,
-                                                                               score]])
+                        Feishu.update_values(log_type, crawler, "DrZHpa", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
+                                                                                     word_list[i]['title'],
+                                                                                     word_list[i]['word'],
+                                                                                     score_time_str,
+                                                                                     score]])
                         Common.logger(log_type, crawler).info("写入飞书成功\n")
                 break
 

+ 26 - 22
weixinzhishu/weixinzhishu_main/weixinzhishu_out.py

@@ -10,6 +10,7 @@ import requests
 sys.path.append(os.getcwd())
 from common.common import Common
 from common.feishu import Feishu
+proxies = {"http": None, "https": None}
 
 
 class Test:
@@ -42,19 +43,19 @@ class Test:
     def get_words(cls, log_type, crawler):
         try:
             while True:
-                sheet = Feishu.get_values_batch(log_type, crawler, '6dsgUk')
+                sheet = Feishu.get_values_batch(log_type, crawler, 'MvFi8s')
                 if sheet is None:
                     Common.logger(log_type, crawler).warning(f"获取热词sheet:{sheet} ,10秒钟后重试")
                     time.sleep(10)
                 else:
                     break
             word_list = []
-            for x in sheet:
-                for y in x:
-                    if y is None:
-                        pass
-                    else:
-                        word_list.append(y)
+            for i in range(len(sheet)):
+                word_dict = {
+                    "title": sheet[i][0],
+                    "word": sheet[i][1]
+                }
+                word_list.append(word_dict)
             return word_list
         except Exception as e:
             Common.logger(log_type, crawler).error(f"get_words:{e}\n")
@@ -67,7 +68,7 @@ class Test:
 
         word_list = cls.get_words(log_type, crawler)
         for i in range(len(word_list)):
-            Common.logger(log_type, crawler).info(f"热词: {word_list[i]}")
+            Common.logger(log_type, crawler).info(f"热词: {word_list[i]['word']}")
             while True:
                 wechat_key = cls.get_wechat_key(log_type, crawler)
                 if wechat_key is None:
@@ -85,7 +86,7 @@ class Test:
                     "cgi_name": "GetDefaultIndex",
                     "start_ymd": start_ymd,
                     "end_ymd": end_ymd,
-                    "query": word_list[i]
+                    "query": word_list[i]['word']
                 })
                 headers = {
                     'Host': 'search.weixin.qq.com',
@@ -93,7 +94,7 @@ class Test:
                     'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x1800202a) NetType/WIFI Language/zh_CN',
                     'Referer': 'https://servicewechat.com/wxc026e7662ec26a3a/42/page-frame.html'
                 }
-                response = requests.request("POST", url, headers=headers, data=payload)
+                response = requests.request("POST", url, headers=headers, data=payload, proxies=proxies)
                 if response.json()['code'] == -10000:
                     Common.logger(log_type, crawler).info(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} response:{response.json()['msg']} 休眠 10 秒,重新获取")
                     time.sleep(10)
@@ -102,20 +103,21 @@ class Test:
                 wechat_score_list = []
                 word_wechat_score_dict = {
                     "id": i+1,
-                    "word": word_list[i],
+                    "word": word_list[i]['word'],
                     "wechatScores": wechat_score_list,
                 }
                 if 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]:
+                    if word_list[i]['word'] in [x for y in Feishu.get_values_batch(log_type, crawler, "YVuVgQ") for x in y]:
                         Common.logger(log_type, crawler).info("该词已存在")
                         continue
-                    Feishu.insert_columns(log_type, crawler, "5011a2", "ROWS", 1, 2)
+                    Feishu.insert_columns(log_type, crawler, "YVuVgQ", "ROWS", 1, 2)
                     time.sleep(0.5)
-                    Feishu.update_values(log_type, crawler, "5011a2", "F2:Z2",
+                    Feishu.update_values(log_type, crawler, "YVuVgQ", "F2:Z2",
                                          [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
-                                           word_list[i],
+                                           word_list[i]['title'],
+                                           word_list[i]['word'],
                                            "",
                                            "该词暂未收录"]])
                     Common.logger(log_type, crawler).info("写入飞书成功\n")
@@ -125,23 +127,25 @@ class Test:
                 else:
                     time_index = response.json()['content']['resp_list'][0]['indexes'][0]['time_indexes']
                     for x in range(len(time_index)):
-                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]}")
+                        Common.logger(log_type, crawler).info(f"正在更新 {word_list[i]['word']}")
                         score_time = time_index[x]['time']
                         score_time_str = f"{str(score_time)[:4]}-{str(score_time)[4:6]}-{str(score_time)[6:]}"
                         score = time_index[x]['score']
                         wechat_score_dict = {"score": score, "scoreDate": score_time_str}
                         wechat_score_list.append(wechat_score_dict)
                         Common.logger(log_type, crawler).info(f"wechat_score_dict:{wechat_score_dict}")
-                        Feishu.insert_columns(log_type, crawler, "5011a2", "ROWS", 1, 2)
+                        Feishu.insert_columns(log_type, crawler, "YVuVgQ", "ROWS", 1, 2)
                         time.sleep(1)
-                        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],
-                                                                               score_time_str,
-                                                                               score]])
+                        Feishu.update_values(log_type, crawler, "YVuVgQ", "F2:Z2", [[time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))),
+                                                                                     word_list[i]['title'],
+                                                                                     word_list[i]['word'],
+                                                                                     score_time_str,
+                                                                                     score]])
                         Common.logger(log_type, crawler).info("写入飞书成功\n")
                 break
 
 
 if __name__ == "__main__":
-    Test.get_score_test("out", "weixinzhishu")
+    # print(Test.get_words("test", "weixinzhishu"))
+    Test.get_score_test("out-1", "weixinzhishu")
     pass