更新代码

This commit is contained in:
JoeamAmier 2023-08-27 10:51:11 +08:00
parent b7bb3ca05c
commit 0af49ceede
2 changed files with 8 additions and 6 deletions

View File

@ -6,8 +6,7 @@ def example():
image_demo = "https://www.xiaohongshu.com/explore/64d1b406000000000103ee8d" image_demo = "https://www.xiaohongshu.com/explore/64d1b406000000000103ee8d"
video_demo = "https://www.xiaohongshu.com/explore/64c05652000000000c0378e7" video_demo = "https://www.xiaohongshu.com/explore/64c05652000000000c0378e7"
xhs = XHS() xhs = XHS()
# print(xhs.get_image(image_demo)) print(xhs.extract(image_demo))
# print(xhs.get_video(video_demo))
print(xhs.extract(video_demo)) print(xhs.extract(video_demo))

View File

@ -1,6 +1,6 @@
from datetime import datetime
from json import loads from json import loads
from re import compile from re import compile
from time import strftime
class Explore: class Explore:
@ -46,9 +46,12 @@ class Explore:
container["作品类型"] = {"video": "视频", "normal": "图文"}[data["type"]] container["作品类型"] = {"video": "视频", "normal": "图文"}[data["type"]]
def __extract_time(self, container: dict, data: dict): def __extract_time(self, container: dict, data: dict):
container["发布时间"] = strftime(self.time_format, data["time"]) container["发布时间"] = datetime.fromtimestamp(
container["最后更新时间"] = strftime( data["time"] / 1000).strftime(self.time_format)
self.time_format, data["lastUpdateTime"]) container["最后更新时间"] = datetime.fromtimestamp(
data["lastUpdateTime"] /
1000).strftime(
self.time_format)
@staticmethod @staticmethod
def __extract_user(container: dict, data: dict): def __extract_user(container: dict, data: dict):