Closed Makkkei closed 4 years ago
michael Lee rui_chon@hotmail.com 于2020年7月7日周二 下午7:29写道:
For example this one: https://www.pixiv.net/en/artworks/81388617
For the code: (user_id is the illustrator id:94883)
json_result = aapi.user_illusts(user_id) for illust in json_result.illusts: aapi.download(illust.image_urls.medium, path=directory, fname='%s.jpg' % (illust.id))
Subject: Re: Pixivpy3 api.download Question
After a brief look, the failure to api.download() may be because the illust contains sensitive content, which needs to be passed by auth like in the api to access.
To test it, you can log out and the illust page will not be accessible.
Currently api.download() does not support auth_token, you can file an issue and I will add it later.
After testing, although pixiv.net prompts you to log in, you can bypass the download directly after obtaining the image_url
through the API:
api = AppPixivAPI()
api.login(_USERNAME, _PASSWORD)
# illust_id = "81388617"
# json_result = api.illust_bookmark_add(illust_id)
# print(json_result)
# get illust info
json_result = api.user_bookmarks_illust('34369276')
illust = json_result.illusts[0]
print(illust)
image_url = illust.meta_single_page.get('original_image_url', illust.image_urls.large)
print(image_url)
# Output: https://i.pximg.net/img-original/img/2020/05/08/00/30/04/81388617_p0.jpg
api.download(image_url)
# api.download("https://i.pximg.net/img-original/img/2020/05/08/00/30/04/81388617_p0.jpg")
api.download()
can download the image to current directory.
Just filing the issue for rmusique@gmail.com since I had already asked the question on email. The answer he/she given is that some illustrations contain sensitive content, which needs to be passed by by auth like in the api to access.