更新代码

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"
video_demo = "https://www.xiaohongshu.com/explore/64c05652000000000c0378e7"
xhs = XHS()
# print(xhs.get_image(image_demo))
# print(xhs.get_video(video_demo))
print(xhs.extract(image_demo))
print(xhs.extract(video_demo))

View File

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