|
@@ -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
|