perf: 支持更多作品链接格式

Closes #272
This commit is contained in:
Quan
2025-07-28 17:00:07 +08:00
parent 5e6f4d9576
commit b63f546b3a
6 changed files with 16 additions and 36 deletions

View File

@@ -75,6 +75,7 @@ class XHS:
VERSION_MINOR = VERSION_MINOR
VERSION_BETA = VERSION_BETA
LINK = compile(r"https?://www\.xiaohongshu\.com/explore/\S+")
USER = compile(r"https?://www\.xiaohongshu\.com/user/profile/[a-z0-9]+/\S+")
SHARE = compile(r"https?://www\.xiaohongshu\.com/discovery/item/\S+")
SHORT = compile(r"https?://xhslink\.com/[^\s\"<>\\^`{|},。;!?、【】《》]+")
ID = compile(r"(?:explore|item)/(\S+)?\?")
@@ -276,6 +277,8 @@ class XHS:
urls.append(u.group())
elif u := self.LINK.search(i):
urls.append(u.group())
elif u := self.USER.search(i):
urls.append(u.group())
return urls
def extract_id(self, links: list[str]) -> list[str]: