Fix get_hot_posts ignoring the limit parameter - #519
Closed
Osamaali313 wants to merge 1 commit into
Closed
Conversation
`XueqiuChannel.get_hot_posts(limit)` documents `limit: 最多返回条数(上限 50)`,
but the request hard-codes the page size to `count=20`:
"?since_id=-1&max_id=-1&count=20&category=-1"
so the server never returns more than 20 posts. The subsequent
`items[:limit]` slice can only shrink those 20 — it can never reach the
documented maximum of 50. `get_hot_posts(limit=50)` silently returns 20.
The two sibling methods in the same file thread `limit` into the page-size
param: `search_stock` uses `&size={limit}` and `get_hot_stocks` uses
`?size={limit}`. Do the same here so the requested count is honored.
Owner
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.
Problem
XueqiuChannel.get_hot_posts(limit)(agent_reach/channels/xueqiu.py) documents its argument aslimit: 最多返回条数(上限 50)("max number of posts to return, up to 50"), but the request hard-codes the page size tocount=20:The server therefore never returns more than 20 posts, and the later
items[:limit]slice can only shrink those 20 — it can never reach the documented maximum. Soget_hot_posts(limit=50)silently returns just 20.Evidence (siblings prove intent)
The two sibling methods in the same file thread
limitinto the page-size parameter:search_stock:f"?code={...}&size={limit}"get_hot_stocks:f"?size={limit}&type={stock_type}"Both then slice
items[:limit].get_hot_postsis the only one that omitslimitfrom the request.Reproduction
Against a stub that honors the URL's page-size (the same contract the
size={limit}siblings rely on):get_hot_posts(limit=50)Fix
f"?since_id=-1&max_id=-1&count={limit}&category=-1"Matches the
size={limit}pattern of both siblings so the requested count is honored.