wangkun 2 lat temu
rodzic
commit
ad8a48480a

BIN
.DS_Store


+ 2 - 3
kuaishou/kuaishou_follow/kuaishou_follow.py

@@ -113,8 +113,7 @@ class KuaiShouFollow:
                 'Accept': '*/*',
                 'Content-Type': 'application/json',
                 'Origin': 'https://www.kuaishou.com',
-                'Cookie': 'kpf=PC_WEB; clientid=3; did=web_921138a59a2c2a70a89fbf0e2d2db6d8; kpn=KUAISHOU_VISION',
-                # 'Cookie': 'kpf=PC_WEB; clientid=3; did=web_7cdc486ebd1aba220455a7781d6ae5b5{r}7; kpn=KUAISHOU_VISION;'.format(r=r),
+                'Cookie': 'kpf=PC_WEB; clientid=3; did=web_34861b8acf21e3e2bdd3fe5b68973e53; kpn=KUAISHOU_VISION',
                 'Content-Length': '552',
                 'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
                 'Host': 'www.kuaishou.com',
@@ -299,7 +298,7 @@ class KuaiShouFollow:
             'Accept': '*/*',
             'Content-Type': 'application/json',
             'Origin': 'https://www.kuaishou.com',
-            'Cookie': 'kpf=PC_WEB; clientid=3; did=web_921138a59a2c2a70a89fbf0e2d2db6d8; kpn=KUAISHOU_VISION',
+            'Cookie': 'kpf=PC_WEB; clientid=3; did=web_34861b8acf21e3e2bdd3fe5b68973e53; kpn=KUAISHOU_VISION',
             'Content-Length': '1260',
             'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
             'Host': 'www.kuaishou.com',

BIN
shipinhao/.DS_Store


BIN
shipinhao/logs/.DS_Store


+ 30 - 14
shipinhao/shipinhao_search/shipinhao_search.py

@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 # @Author: wangkun
 # @Time: 2023/4/25
+import datetime
 import difflib
 import os
 import sys
@@ -300,10 +301,26 @@ class ShipinhaoSearch:
             days = int(publish_time.replace("天前", ""))
             publish_time_str = (date.today() + timedelta(days=-days)).strftime("%Y-%m-%d")
         elif "年" in publish_time:
-            publish_time_str = publish_time.replace("年", "-").replace("月", "-").replace("日", "")
+            # publish_time_str = publish_time.replace("年", "-").replace("月", "-").replace("日", "")
+            year_str = publish_time.split("年")[0]
+            month_str = publish_time.split("年")[-1].split("月")[0]
+            day_str = publish_time.split("月")[-1].split("日")[0]
+            if int(month_str) < 10:
+                month_str = f"0{month_str}"
+            if int(day_str) < 10:
+                day_str = f"0{day_str}"
+            publish_time_str = f"{year_str}-{month_str}-{day_str}"
         else:
-            publish_time_str = f'2023-{publish_time.replace("月", "-").replace("日", "")}'
-        # publish_time_stamp = int(time.mktime(time.strptime(publish_time_str, "%Y-%m-%d")))
+            year_str = str(datetime.datetime.now().year)
+            month_str = publish_time.split("月")[0]
+            day_str = publish_time.split("月")[-1].split("日")[0]
+            if int(month_str) < 10:
+                month_str = f"0{month_str}"
+            if int(day_str) < 10:
+                day_str = f"0{day_str}"
+            publish_time_str = f"{year_str}-{month_str}-{day_str}"
+            # publish_time_str = f'2023-{publish_time.replace("月", "-").replace("日", "")}'
+        publish_time_stamp = int(time.mktime(time.strptime(publish_time_str, "%Y-%m-%d")))
 
         # 收起评论
         # Common.logger(log_type, crawler).info("收起评论")
@@ -324,7 +341,7 @@ class ShipinhaoSearch:
             "favorite_cnt": favorite_cnt,
             "comment_cnt": comment_cnt,
             "publish_time_str": publish_time_str,
-            # "publish_time_stamp": publish_time_stamp,
+            "publish_time_stamp": publish_time_stamp,
         }
         return video_dict
 
@@ -334,17 +351,16 @@ class ShipinhaoSearch:
         for word in word_list:
             cls.i = 0
             Common.logger(log_type, crawler).info(f"开始抓取搜索词:{word}")
-            try:
-                cls.start_wechat(log_type=log_type,
-                                 crawler=crawler,
-                                 word=word,
-                                 env=env)
-            except Exception as e:
-                Common.logger(log_type, crawler).error(f"search_video:{e}\n")
+            # try:
+            cls.start_wechat(log_type=log_type,
+                             crawler=crawler,
+                             word=word,
+                             env=env)
+            # except Exception as e:
+            #     Common.logger(log_type, crawler).error(f"search_video:{e}\n")
 
 
 if __name__ == '__main__':
-    ShipinhaoSearch.search_all_videos(log_type="search",
-                                      crawler="shipinhao",
-                                      env="dev")
+    ShipinhaoSearch.search_all_videos(log_type="search", crawler="shipinhao", env="dev")
+    # print(datetime.datetime.now().year)
     pass