Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何解决offset不能超过5000的限制? #336

Open
xiyihan0 opened this issue Feb 27, 2024 · 2 comments
Open

如何解决offset不能超过5000的限制? #336

xiyihan0 opened this issue Feb 27, 2024 · 2 comments
Labels

Comments

@xiyihan0
Copy link
Contributor

我在尝试使用aapi时,为其自定义了一个方法:

    def illust_bookmark_users(
        self, illust_id: int | str, offset: int | str | None = None, req_auth: bool = True
    ) -> ParsedJson:
        url = "%s/v1/illust/bookmark/users" % self.hosts
        params = {
            "illust_id": illust_id,
        }
        if offset:
            params["offset"] = offset
        r = self.no_auth_requests_call("GET", url, params=params, req_auth=req_auth)
        return self.parse_result(r)

用于获取谁收藏了某个插画。
然而在使用过程中,遇到了一个问题:offset不能超过5000,一旦超过则api就会返回错误信息:

_ACCESS_TOKEN = "..."
_REFRESH_TOKEN = "..."
from pixivpy3 import *
api = AppPixivAPI()
api.set_auth(access_token = _ACCESS_TOKEN,refresh_token=_REFRESH_TOKEN)
print(api.illust_bookmark_users(116190229, offset=4980)) # OK
print(api.illust_bookmark_users(116190229, offset=5010)) # {'error': {'user_message': 'Invalid request.', 'message': '',  'reason': '',  'user_message_details': {}}}

请问有什么方法能绕过此限制?

@Xdynix
Copy link
Collaborator

Xdynix commented Feb 27, 2024

只使用aapi很难绕过此限制,除非能找到服务器程序的漏洞。你只能考虑使用其他平台的API了,如模拟网页浏览器的请求。

@upbit upbit added the question label Mar 3, 2024
@upbit
Copy link
Owner

upbit commented Mar 3, 2024

嗯,App-API是针对手机设计的。如果你需要抓取全部内容,可能考虑网页端用Webdriver获取更容易,对应接口是:

GET /users/{user_id}/bookmarks/artworks?p={页码}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants