feat(xiaohongshu): add search filter panel options (--sort/--note-type/--publish-time/--scope/--location) - #2276
Open
xemaya wants to merge 1 commit into
Open
Conversation
Xiaohongshu's web search filter panel (排序依据/笔记类型/发布时间/搜索范围/位置距离) is not URL-addressable: selecting a chip fires a signed /api/sns/web/v1/search/notes XHR with a filters array. This adds five options to xiaohongshu search that drive the panel chips after navigation and wait for each re-render before extraction: --sort comprehensive|latest|most-liked|most-commented|most-collected --note-type all|video|image --publish-time anytime|day|week|half-year --scope all|seen|unseen|following --location all|same-city|nearby Chip texts and behavior were verified against live XHR request bodies. Filters left at their default are skipped, preserving prior behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds five filter options to
opencli xiaohongshu search, mirroring the web search filter panel (筛选):--sort--note-type--publish-time--scope--locationExample:
opencli xiaohongshu search 美食 --limit 10 --sort latest --publish-time dayWhy
The command previously exposed no way to filter or sort results; users had to post-filter
published_atclient-side, which wastes results budget (--limitmax 100) and cannot express sort order at all.How
Xiaohongshu's web search does not encode filters in the URL — selecting a chip fires a signed
/api/sns/web/v1/search/notesXHR with afiltersarray, e.g.{"tags":["time_descending"],"type":"sort_type"}. Since this adapter is DOM-based (the header comment documents why the XHR approach broke), the implementation reproduces the user's own clicks:buildApplyFiltersJs()opens the 筛选 panel (toggle reads 筛选 when idle, 已筛选 when filters are active — both matched).Chip display texts for all five groups were verified against live XHR request bodies. Filters left at their default value are skipped entirely, so existing behavior is unchanged when no new flag is passed. Failures (panel or chip not found, e.g. a XHS layout change) raise a typed
CommandExecutionErrorinstead of silently returning unfiltered results.Testing
clis/xiaohongshu/search.test.js(mapping, IIFE generation, panel driving order, typed failure, no-panel-when-default).npx tsc --noEmitclean; full suite: 590 files / 6741 tests passed.--publish-time dayreturned only notes from the last 24h,--sort most-likedreturned descending like counts,--location same-cityreturned local-city results.