wangkun 2 years ago
parent
commit
0306229d36
1 changed files with 14 additions and 13 deletions
  1. 14 13
      kuaishou/kuaishou_follow/kuaishou_follow.py

+ 14 - 13
kuaishou/kuaishou_follow/kuaishou_follow.py

@@ -113,7 +113,7 @@ class KuaiShouFollow:
                 'Accept': '*/*',
                 'Content-Type': 'application/json',
                 'Origin': 'https://www.kuaishou.com',
-                'Cookie': 'kpf=PC_WEB; clientid=3; did=web_9d5ea328df00c51abab6fdcaeb594311; kpn=KUAISHOU_VISION',
+                'Cookie': f'kpf=PC_WEB; clientid=3; did={cls.get_did(log_type, crawler)}; kpn=KUAISHOU_VISION',
                 'Content-Length': '552',
                 'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
                 'Host': 'www.kuaishou.com',
@@ -275,6 +275,16 @@ class KuaiShouFollow:
         else:
             return video_title
 
+    @classmethod
+    def get_did(cls, log_type, crawler):
+        while True:
+            did_sheet = Feishu.get_values_batch(log_type, crawler, "G7acT6")
+            if did_sheet is None:
+                Common.logger(log_type, crawler).warning(f"did_sheet:{did_sheet}")
+                time.sleep(2)
+                continue
+            return did_sheet[0][1]
+
     @classmethod
     def get_videoList(cls, log_type, crawler, strategy, our_uid, out_uid, oss_endpoint, env, machine, pcursor=""):
         download_cnt_1, download_cnt_2 = 0, 0
@@ -298,7 +308,7 @@ class KuaiShouFollow:
             'Accept': '*/*',
             'Content-Type': 'application/json',
             'Origin': 'https://www.kuaishou.com',
-            'Cookie': 'kpf=PC_WEB; clientid=3; did=web_9d5ea328df00c51abab6fdcaeb594311; kpn=KUAISHOU_VISION',
+            'Cookie': f'kpf=PC_WEB; clientid=3; did={cls.get_did(log_type, crawler)}; kpn=KUAISHOU_VISION',
             'Content-Length': '1260',
             'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
             'Host': 'www.kuaishou.com',
@@ -649,14 +659,5 @@ class KuaiShouFollow:
 
 
 if __name__ == "__main__":
-    KuaiShouFollow.get_videoList(log_type="follow",
-                                 crawler="kuaishou",
-                                 strategy="定向爬虫策略",
-                                 our_uid="54719554",
-                                 out_uid="3xnk3wbm3vfiha6",
-                                 oss_endpoint="out",
-                                 env="dev",
-                                 machine="local")
-
-    # print(KuaiShouFollow.get_out_user_info("follow", "kuaishou", "3xnk3wbm3vfiha6"))
-    # print(Follow.get_out_user_info("follow", "kuaishou", "3x5wgjhfc7tx8ue"))
+    print(KuaiShouFollow.get_did("follow", "kuaishou"))
+    pass