Skip to content

Commit

Permalink
MOD:修复翻页偏移问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ShilongLee committed Jul 18, 2024
1 parent dfd19de commit 76db093
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion service/bilibili/logic/replys.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def request_replys(id: str, comment_id: str, cookie: str, offset: int = 0,
oid = data.get('aid', 0)

page_size = 10
start_page = int((offset - 1) / page_size ) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
comments = []
total = 0
Expand Down
2 changes: 1 addition & 1 deletion service/bilibili/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
请求bilibili获取搜索信息
"""
page_size = 20
start_page = int((offset - 1) / page_size )+ 1
start_page = int( offset / page_size )+ 1
end_page = int((offset + limit - 1) / page_size) + 1
ret = []
tasks = [request_page(keyword, cookie, page) for page in range(start_page, end_page + 1)]
Expand Down
2 changes: 1 addition & 1 deletion service/bilibili/logic/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def request_user(id: str, cookie: str, offset: int = 0, limit: int = 30) -
"""
ret = {}
page_size = 30
start_page = int((offset - 1) / page_size) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
videos = []
total = 0
Expand Down
4 changes: 2 additions & 2 deletions service/jd/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
"""
results = []
page_size = 30
start_page = int((offset - 1) / page_size ) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
keyword = quote(keyword)
total = 0
Expand All @@ -26,7 +26,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
total = _total
results.extend(data)
ret = {"results": results[(offset % page_size):(offset % page_size + limit)], "total": total}
return ret, True
return ret

async def search(keyword: str, page: int, cookie: str) -> tuple[list, int]:
query = f'?keyword={keyword}&page={page}'
Expand Down
2 changes: 1 addition & 1 deletion service/kuaishou/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
pcursor = ''
headers = {"Cookie": cookie}
page_size = 20
start_page = int((offset - 1) / page_size ) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
ret = []
search_session_id = None
Expand Down
2 changes: 1 addition & 1 deletion service/taobao/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
"""
results = []
page_size = 48
start_page = int((offset - 1) / page_size ) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
total = 0

Expand Down
2 changes: 1 addition & 1 deletion service/weibo/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
results = []
total = 0
page_size = 10
start_page = int((offset - 1) / page_size )+ 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
tasks = [request_page(page, keyword, cookie) for page in range(start_page, end_page + 1)]
pages = await asyncio.gather(*tasks)
Expand Down
2 changes: 1 addition & 1 deletion service/weibo/logic/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def request_user(id: str, cookie: str, offset: int = 0, limit: int = 5) ->
"""
ret = {}
page_size = 5
start_page = int((offset - 1) / page_size) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
weibos = []
total = 0
Expand Down
2 changes: 1 addition & 1 deletion service/xhs/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
请求小红书获取搜索信息
"""
page_size = 20
start_page = int((offset - 1) / page_size) + 1
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js').read())
tasks = [request_page(page, keyword, cookie, page_size, xhs_sign_obj) for page in range(start_page, end_page + 1)]
Expand Down

0 comments on commit 76db093

Please sign in to comment.