wangkun 2 роки тому
батько
коміт
f729e47869
1 змінених файлів з 49 додано та 45 видалено
  1. 49 45
      main/xiaoniangao_person_list.py

+ 49 - 45
main/xiaoniangao_person_list.py

@@ -176,6 +176,7 @@ class Person:
             unfollow_sheet = Feishu.get_values_batch(log_type, "xiaoniangao", "tuMNhn")
             if len(unfollow_sheet) == 1:
                 Common.logger(log_type).info("暂无定向账号")
+                return None
             else:
                 unfollow_list = []
                 nick_list = []
@@ -250,53 +251,56 @@ class Person:
     def unsub_users(cls, log_type):
         try:
             unsub_profile_mids = cls.get_unfollow_users(log_type)
-            for profile_mid in unsub_profile_mids:
-                url = "https://api.xiaoniangao.cn/V1/account/unsub_user"
-                headers = {
-                    "x-b3-traceid": str(cls.follow_x_mid),
-                    "X-Token-Id": str(cls.follow_x_token_id),
-                    "content-type": "application/json",
-                    "uuid": str(cls.follow_uid),
-                    "Accept-Encoding": "gzip,compress,br,deflate",
-                    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)"
-                                  " AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 "
-                                  "MicroMessenger/8.0.20(0x18001435) NetType/WIFI Language/zh_CN",
-                    "Referer": str(cls.follow_referer)
-                }
-                data = {
-                    "visited_mid": int(profile_mid),
-                    "log_common_params": {
-                        "e": [{
-                            "data": {
-                                "page": "profilePage",
-                                "topic": "public",
-                                "type": "unfollow",
-                                "name": "user",
-                                "smid": str(profile_mid)
+            if unsub_profile_mids is None:
+                pass
+            else:
+                for profile_mid in unsub_profile_mids:
+                    url = "https://api.xiaoniangao.cn/V1/account/unsub_user"
+                    headers = {
+                        "x-b3-traceid": str(cls.follow_x_mid),
+                        "X-Token-Id": str(cls.follow_x_token_id),
+                        "content-type": "application/json",
+                        "uuid": str(cls.follow_uid),
+                        "Accept-Encoding": "gzip,compress,br,deflate",
+                        "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X)"
+                                      " AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 "
+                                      "MicroMessenger/8.0.20(0x18001435) NetType/WIFI Language/zh_CN",
+                        "Referer": str(cls.follow_referer)
+                    }
+                    data = {
+                        "visited_mid": int(profile_mid),
+                        "log_common_params": {
+                            "e": [{
+                                "data": {
+                                    "page": "profilePage",
+                                    "topic": "public",
+                                    "type": "unfollow",
+                                    "name": "user",
+                                    "smid": str(profile_mid)
+                                },
+                                "ab": {}
+                            }],
+                            "ext": {
+                                "brand": "iPhone",
+                                "device": "iPhone 11",
+                                "os": "iOS 14.7.1",
+                                "weixinver": "8.0.20",
+                                "srcver": "2.24.4",
+                                "net": "wifi",
+                                "scene": "1089"
                             },
-                            "ab": {}
-                        }],
-                        "ext": {
-                            "brand": "iPhone",
-                            "device": "iPhone 11",
-                            "os": "iOS 14.7.1",
-                            "weixinver": "8.0.20",
-                            "srcver": "2.24.4",
-                            "net": "wifi",
-                            "scene": "1089"
+                            "pj": "1",
+                            "pf": "2",
+                            "session_id": "6a2959c7-3f98-411f-8bc9-8d2a8a5c6f16"
                         },
-                        "pj": "1",
-                        "pf": "2",
-                        "session_id": "6a2959c7-3f98-411f-8bc9-8d2a8a5c6f16"
-                    },
-                    "token": str(cls.follow_token),
-                    "uid": str(cls.follow_uid),
-                    "proj": "ma",
-                    "wx_ver": "8.0.20",
-                    "code_ver": "3.64.1"}
-                urllib3.disable_warnings()
-                r = requests.post(headers=headers, url=url, json=data, proxies=proxies, verify=False)
-                Common.logger(log_type).info("取消关注:{},{}", profile_mid, r)
+                        "token": str(cls.follow_token),
+                        "uid": str(cls.follow_uid),
+                        "proj": "ma",
+                        "wx_ver": "8.0.20",
+                        "code_ver": "3.64.1"}
+                    urllib3.disable_warnings()
+                    r = requests.post(headers=headers, url=url, json=data, proxies=proxies, verify=False)
+                    Common.logger(log_type).info("取消关注:{},{}", profile_mid, r)
         except Exception as e:
             Common.logger(log_type).error("取消关注云文档中的用户异常:{}", e)