Skip to content

Commit bbc42e8

Browse files
author
Anonymous Committer
committed
feat: add xiaohongshu.search_note_v1
1 parent 9828d37 commit bbc42e8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

justoneapi/apis/xiaohongshu.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,28 @@ def get_note_sub_comment_v3(self, note_id: str, comment_id: str, last_cursor: st
160160
logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
161161
return result, data, message, has_next_page
162162

163+
def search_note_v1(self, keyword: str, page: int, sort: str, note_type: str, note_time: str = None):
164+
url = f"{self.base_url}/api/xiaohongshu/search-note/v1"
165+
params = {
166+
"token": self.token,
167+
"keyword": keyword,
168+
"page": page,
169+
"sort": sort,
170+
"noteType": note_type,
171+
}
172+
if note_time:
173+
params["noteTime"] = note_time
174+
175+
has_next_page = False
176+
result, data, message = request_util.get_request_page(url, params)
177+
try:
178+
if data:
179+
if data.get("items"):
180+
has_next_page = True
181+
except Exception as e:
182+
logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
183+
return result, data, message, has_next_page
184+
163185
def search_note_v2(self, keyword: str, page: int, sort: str, note_type: str, note_time: str = None):
164186
url = f"{self.base_url}/api/xiaohongshu/search-note/v2"
165187
params = {

tests/test_xiaohongshu.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ def test_get_note_feed_v1(self):
5151
result, data, message = self.client.xiaohongshu.get_note_feed_v1(oid="homefeed_recommend", page=1)
5252
if result:
5353
print(json.dumps(data, ensure_ascii=False))
54+
55+
def test_search_note_v1(self):
56+
result, data, message, has_next_page = self.client.xiaohongshu.search_note_v1(keyword="deepseek", page=1,
57+
sort="general", note_type="_0")
58+
if result:
59+
print(json.dumps(data, ensure_ascii=False))

0 commit comments

Comments
 (0)