Pixiv API for Python
See the codeDue to #158 reason, password login no longer exist. Please use
api.auth(refresh_token=REFRESH_TOKEN)instead.To get
refresh_token, see @ZipFile Pixiv OAuth Flow / gppt: get-pixivpy-token (Easy to use 👍 base on selenium) / OAuth with Selenium/ChromeDriver
Pixiv API for Python (with Auth supported)
pydantic models for App-API (thanks
@Danipulok)novel_text() BUG, add webview_novel(), see
#337 (thanks
@xiyihan)novel_follow(), fix ByPassSniApi() host BUG, see
#279 (thanks
@Solomon,
@rhyryy)illust_new for get latest works, see
#189follow/unfollow, add novel API, see
#161 (thanks
@y-young,
@invobzvr)search_illust() (thanks
Xdynix)AppPixivAPI().search_novel() for novel searchX-Client-Time/X-Client-Hash (thanks
DaRealFreak,
#83)illust_bookmark_add()/illust_bookmark_delete() params (thanks
naplings)PixivAPI().works() liked API illust_detail() for App-API
(thanks Mapaler), release v3.3AppPixivAPI() can call without auth (thanks
zzycami), check
demo.pyPixivIOSApp/6.0.9Use pip for installing:
# for Python3
pip install pixivpy3 --upgrade
# for Python2
pip install pixivpy --upgrade
Requirements: requests
性能对比(需要高性能访问场景,可以参 考这个脚本)
Warning: The rate limit was hit multiple times during the test, so the result may not be informative. Script: https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py
sg -> Singapore, jp -> Japan, unit -> second
| Method | Sync(10,sg) | Async(10,sg) | Sync(200,sg) | Async(200,sg) |
|---|---|---|---|---|
| illust_detail | 1.1209 | 0.8641 | 31.7041 | 2.4580 |
| illust_ranking | 1.0697 | 0.7936 | 28.4539 | 2.0693 |
| user_illusts | 0.8824 | 0.7505 | 28.3981 | 1.8199 |
| user_detail | 0.9628 | 0.7550 | 28.3055 | 1.7738 |
| ugoira_metadata | 0.8509 | 0.7459 | 29.5566 | 2.2331 |
| works | 1.1204 | 0.8912 | 32.2068 | 2.8513 |
| me_following_works | 1.1253 | 0.7845 | 39.3142 | 2.2785 |
| ranking | 1.0946 | 0.7944 | 39.6509 | 2.6548 |
| latest_works | 1.0483 | 0.8667 | 36.1992 | 2.5066 |
| Method | Sync(500,jp) | Async(500,jp) |
|---|---|---|
| illust_detail | 6.2178 | 0.6400 |
| illust_ranking | 6.4046 | 0.6119 |
| user_illusts | 7.6093 | 1.5266 |
| user_detail | 6.6759 | 0.5952 |
| ugoira_metadata | 6.5155 | 0.7577 |
| works | 13.3074 | 0.8619 |
| me_following_works | 24.2693 | 2.0835 |
| ranking | 21.4119 | 3.2805 |
| latest_works | 17.3502 | 2.7029 |
from pixivpy3 import AppPixivAPI
access_token = "..."
refresh_token = "..."
api = AppPixivAPI()
api.set_auth(access_token, refresh_token)
# get origin url
json_result = api.illust_detail(59580629)
illust = json_result.illust
print(f">>> origin url: {illust.image_urls.large}")
# get ranking: 1-30
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
json_result = api.illust_ranking('day')
for illust in json_result.illusts:
print(f" p1 [{illust.title}] {illust.image_urls.medium}")
# next page: 31-60
next_qs = api.parse_qs(json_result.next_url)
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print(f" p2 [{illust.title}] {illust.image_urls.medium}")
# get all page:
next_qs = {"mode": "day"}
while next_qs:
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print(f"[{illust.title}] {illust.image_urls.medium}")
next_qs = api.parse_qs(json_result.next_url)
pip install pixivpy --upgradeapi.download() like the below:from pixivpy3 import AppPixivAPI
aapi = AppPixivAPI()
json_result = aapi.illust_ranking()
for illust in json_result.illusts[:3]:
aapi.download(illust.image_urls.large)
api.papi.* to api.*from pixivpy3 import AppPixivAPI
api = AppPixivAPI()
rank_list = api.illust_ranking('day')
print(rank_list)
# more fields about response: https://github.com/upbit/pixivpy/wiki/sniffer
ranking = rank_list.response[0]
for img in ranking.works:
# print(img.work)
print(f"[{img.work.user.name}/{img.work.title}(id={img.work.id})] {img.work.image_urls.px_480mw}")
If you have any questions, please feel free to contact me: rmusique@gmail.com
Find Pixiv API in Objective-C? You might also like PixivAPI_iOS
from __future__ import annotations
from typing import Any
from pixivpy3.utils import ParsedJson
from pixivpy3.api import BasePixivAPI
class AppPixivAPI(BasePixivAPI):
# 返回翻页用参数
def parse_qs(cls, next_url: str | None) -> dict[str, Any] | None: ...
# 用户详情
def user_detail(self, user_id: int | str) -> ParsedJson: ...
# 用户作品列表
## type: [illust, manga]
def user_illusts(self, user_id: int | str, type="illust") -> ParsedJson: ...
# 用户收藏作品列表
# tag: 从 user_bookmark_tags_illust 获取的收藏标签
def user_bookmarks_illust(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# 用户收藏作品列表中的小说
def user_bookmarks_novel(self, user_id: int | str, restrict="public") -> ParsedJson: ...
def user_related(self, seed_user_id: int | str) -> ParsedJson: ...
# 关注用户的新作
# restrict: [public, private]
def illust_follow(self, restrict="public") -> ParsedJson: ...
# 作品详情 (类似PAPI.works(),iOS中未使用)
def illust_detail(self, illust_id: int | str) -> ParsedJson: ...
# 作品评论
def illust_comments(self, illust_id: int | str, include_total_comments=None) -> ParsedJson: ...
# 相关作品列表
def illust_related(self, illust_id: int | str) -> ParsedJson: ...
# 插画推荐 (Home - Main)
# content_type: [illust, manga]
def illust_recommended(self, content_type="illust") -> ParsedJson: ...
# 小说推荐
def novel_recommended(self) -> ParsedJson: ...
# 作品排行
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
# date: '2016-08-01'
# mode (Past): [day, week, month, day_male, day_female, week_original, week_rookie,
# day_r18, day_male_r18, day_female_r18, week_r18, week_r18g]
def illust_ranking(self, mode="day", date=None) -> ParsedJson: ...
# 趋势标签 (Search - tags)
def trending_tags_illust(self) -> ParsedJson: ...
# 搜索 (Search)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# title_and_caption - 标题说明文
# sort: [date_desc, date_asc, popular_desc] - popular_desc为会员的热门排序
# duration: [within_last_day, within_last_week, within_last_month]
# start_date, end_date: '2020-07-01'
def search_illust(
self,
word: str,
search_target="partial_match_for_tags",
sort="date_desc",
duration=None,
start_date=None,
end_date=None,
) -> ParsedJson: ...
# 搜索小说 (Search Novel)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# text - 正文
# keyword - 关键词
# sort: [date_desc, date_asc]
# start_date/end_date: 2020-06-01
def search_novel(
self,
word: str,
search_target="partial_match_for_tags",
sort="date_desc",
start_date=None,
end_date=None,
) -> ParsedJson: ...
def search_user(self, word: str, sort='date_desc', duration=None) -> ParsedJson: ...
# 作品收藏详情
def illust_bookmark_detail(self, illust_id: int | str) -> ParsedJson: ...
# 新增收藏
def illust_bookmark_add(self, illust_id: int | str, restrict="public", tags=None) -> ParsedJson: ...
# 删除收藏
def illust_bookmark_delete(self, illust_id: int | str) -> ParsedJson: ...
# 关注用户
def user_follow_add(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# 取消关注用户
def user_follow_delete(self, user_id: int | str) -> ParsedJson: ...
# 用户收藏标签列表
def user_bookmark_tags_illust(self, restrict="public") -> ParsedJson: ...
# Following用户列表
def user_following(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# Followers用户列表
def user_follower(self, user_id: int | str) -> ParsedJson: ...
# 好P友
def user_mypixiv(self, user_id: int | str) -> ParsedJson: ...
# 黑名单用户
def user_list(self, user_id: int | str) -> ParsedJson: ...
# 获取ugoira信息
def ugoira_metadata(self, illust_id: int | str) -> ParsedJson: ...
# 用户小说列表
def user_novels(self, user_id: int | str) -> ParsedJson: ...
# 小说系列详情
def novel_series(self, series_id: int | str, last_order=None) -> ParsedJson: ...
# 小说详情
def novel_detail(self, novel_id: int | str) -> ParsedJson: ...
# 小说 (包含正文)
def webview_novel(self, novel_id: int | str) -> ParsedJson: ...
# 小说评论
def novel_comments(self, novel_id: int | str) -> ParsedJson: ...
# 大家的新作
# content_type: [illust, manga]
def illust_new(self, content_type="illust", max_illust_id=None) -> ParsedJson: ...
def novel_new(self, max_novel_id=None) -> ParsedJson: ...
# 特辑详情 (无需登录,调用Web API)
def showcase_article(self, showcase_id) -> ParsedJson: ...
from pixivpy3 import AppPixivAPI
api = AppPixivAPI()
# 作品推荐
json_result = api.illust_recommended()
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 作品相关推荐
json_result = api.illust_related(57065990)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 作品相关推荐-下一页 (.parse_qs(next_url) 用法)
next_qs = api.parse_qs(json_result.next_url)
json_result = api.illust_related(**next_qs)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户详情
json_result = api.user_detail(660788)
print(json_result)
user = json_result.user
print(f"{user.name}(@{user.account}) region={json_result.profile.region}")
# 用户作品列表
json_result = api.user_illusts(660788)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户收藏列表
json_result = api.user_bookmarks_illust(2088434)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户收藏列表中的小说
json_result = api.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(f">>> {novel.title}, text_length: {novel.text_length}, series: {novel.series}")
# 2016-07-15 日的过去一周排行
json_result = api.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 关注用户的新作 (需要login)
json_result = api.illust_follow(req_auth=True)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 标签 "水着" 搜索
json_result = api.search_illust('水着', search_target='partial_match_for_tags')
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户 "gomzi" 搜索
json_result = api.search_user("gomzi")
print(json_result)
illust = json_result.user_previews[0].illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 展示小说评论区
json_result = api.novel_comments(16509454, include_total_comments=True)
print(f"Total comments = {json_result.total_comments}")
for comment in json_result.comments:
if comment.parent_comment:
print(f"{comment.user.name} replied to {comment.parent_comment.user.name} at {comment.date} : {comment.comment}")
else:
print(f"{comment.user.name} at {comment.date} : {comment.comment}")
# Updating dependencies
$ poetry update --with=dev,test
Fork this project and create a new branch for your changes. Push your changes to your fork and create a pull request.
poetry run pytest
Follow these simple steps to publish your Poetry package. We recommend publishing to the test.pypi.org instance first, to verify everything is working as expected.
This step only has to be done once:
# Configure test.pypi.org
poetry config repositories.testpypi https://test.pypi.org/legacy/
# Configure API Keys for both PyPI and TestPyPY
poetry config pypi-token.testpypi <testpypi_api_key>
poetry config pypi-token.pypi <pypi_api_key>
Now publish the new version:
# Adjust the package version at the top of the "pyproject.toml" file
vim pyproject.toml
# Build python packages to dist/ folder
poetry build
# Publish package to TestPyPi
poetry publish -r testpypi
# Checkout published package in a different environment
pip install --index-url https://test.pypi.org/simple/ <your_package_name>
# Once confirmed that everything works, publish to the real PyPi
poetry publish
Feel free to use, reuse and abuse the code in this project.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
339 followers · starred Aug 2017
54 followers · starred May 2022
20 followers · starred Aug 2020
45 followers · starred Jan 2022
Pixiv API for Python
See the codeDue to #158 reason, password login no longer exist. Please use
api.auth(refresh_token=REFRESH_TOKEN)instead.To get
refresh_token, see @ZipFile Pixiv OAuth Flow / gppt: get-pixivpy-token (Easy to use 👍 base on selenium) / OAuth with Selenium/ChromeDriver
Pixiv API for Python (with Auth supported)
pydantic models for App-API (thanks
@Danipulok)novel_text() BUG, add webview_novel(), see
#337 (thanks
@xiyihan)novel_follow(), fix ByPassSniApi() host BUG, see
#279 (thanks
@Solomon,
@rhyryy)illust_new for get latest works, see
#189follow/unfollow, add novel API, see
#161 (thanks
@y-young,
@invobzvr)search_illust() (thanks
Xdynix)AppPixivAPI().search_novel() for novel searchX-Client-Time/X-Client-Hash (thanks
DaRealFreak,
#83)illust_bookmark_add()/illust_bookmark_delete() params (thanks
naplings)PixivAPI().works() liked API illust_detail() for App-API
(thanks Mapaler), release v3.3AppPixivAPI() can call without auth (thanks
zzycami), check
demo.pyPixivIOSApp/6.0.9Use pip for installing:
# for Python3
pip install pixivpy3 --upgrade
# for Python2
pip install pixivpy --upgrade
Requirements: requests
性能对比(需要高性能访问场景,可以参 考这个脚本)
Warning: The rate limit was hit multiple times during the test, so the result may not be informative. Script: https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py
sg -> Singapore, jp -> Japan, unit -> second
| Method | Sync(10,sg) | Async(10,sg) | Sync(200,sg) | Async(200,sg) |
|---|---|---|---|---|
| illust_detail | 1.1209 | 0.8641 | 31.7041 | 2.4580 |
| illust_ranking | 1.0697 | 0.7936 | 28.4539 | 2.0693 |
| user_illusts | 0.8824 | 0.7505 | 28.3981 | 1.8199 |
| user_detail | 0.9628 | 0.7550 | 28.3055 | 1.7738 |
| ugoira_metadata | 0.8509 | 0.7459 | 29.5566 | 2.2331 |
| works | 1.1204 | 0.8912 | 32.2068 | 2.8513 |
| me_following_works | 1.1253 | 0.7845 | 39.3142 | 2.2785 |
| ranking | 1.0946 | 0.7944 | 39.6509 | 2.6548 |
| latest_works | 1.0483 | 0.8667 | 36.1992 | 2.5066 |
| Method | Sync(500,jp) | Async(500,jp) |
|---|---|---|
| illust_detail | 6.2178 | 0.6400 |
| illust_ranking | 6.4046 | 0.6119 |
| user_illusts | 7.6093 | 1.5266 |
| user_detail | 6.6759 | 0.5952 |
| ugoira_metadata | 6.5155 | 0.7577 |
| works | 13.3074 | 0.8619 |
| me_following_works | 24.2693 | 2.0835 |
| ranking | 21.4119 | 3.2805 |
| latest_works | 17.3502 | 2.7029 |
from pixivpy3 import AppPixivAPI
access_token = "..."
refresh_token = "..."
api = AppPixivAPI()
api.set_auth(access_token, refresh_token)
# get origin url
json_result = api.illust_detail(59580629)
illust = json_result.illust
print(f">>> origin url: {illust.image_urls.large}")
# get ranking: 1-30
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
json_result = api.illust_ranking('day')
for illust in json_result.illusts:
print(f" p1 [{illust.title}] {illust.image_urls.medium}")
# next page: 31-60
next_qs = api.parse_qs(json_result.next_url)
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print(f" p2 [{illust.title}] {illust.image_urls.medium}")
# get all page:
next_qs = {"mode": "day"}
while next_qs:
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print(f"[{illust.title}] {illust.image_urls.medium}")
next_qs = api.parse_qs(json_result.next_url)
pip install pixivpy --upgradeapi.download() like the below:from pixivpy3 import AppPixivAPI
aapi = AppPixivAPI()
json_result = aapi.illust_ranking()
for illust in json_result.illusts[:3]:
aapi.download(illust.image_urls.large)
api.papi.* to api.*from pixivpy3 import AppPixivAPI
api = AppPixivAPI()
rank_list = api.illust_ranking('day')
print(rank_list)
# more fields about response: https://github.com/upbit/pixivpy/wiki/sniffer
ranking = rank_list.response[0]
for img in ranking.works:
# print(img.work)
print(f"[{img.work.user.name}/{img.work.title}(id={img.work.id})] {img.work.image_urls.px_480mw}")
If you have any questions, please feel free to contact me: rmusique@gmail.com
Find Pixiv API in Objective-C? You might also like PixivAPI_iOS
from __future__ import annotations
from typing import Any
from pixivpy3.utils import ParsedJson
from pixivpy3.api import BasePixivAPI
class AppPixivAPI(BasePixivAPI):
# 返回翻页用参数
def parse_qs(cls, next_url: str | None) -> dict[str, Any] | None: ...
# 用户详情
def user_detail(self, user_id: int | str) -> ParsedJson: ...
# 用户作品列表
## type: [illust, manga]
def user_illusts(self, user_id: int | str, type="illust") -> ParsedJson: ...
# 用户收藏作品列表
# tag: 从 user_bookmark_tags_illust 获取的收藏标签
def user_bookmarks_illust(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# 用户收藏作品列表中的小说
def user_bookmarks_novel(self, user_id: int | str, restrict="public") -> ParsedJson: ...
def user_related(self, seed_user_id: int | str) -> ParsedJson: ...
# 关注用户的新作
# restrict: [public, private]
def illust_follow(self, restrict="public") -> ParsedJson: ...
# 作品详情 (类似PAPI.works(),iOS中未使用)
def illust_detail(self, illust_id: int | str) -> ParsedJson: ...
# 作品评论
def illust_comments(self, illust_id: int | str, include_total_comments=None) -> ParsedJson: ...
# 相关作品列表
def illust_related(self, illust_id: int | str) -> ParsedJson: ...
# 插画推荐 (Home - Main)
# content_type: [illust, manga]
def illust_recommended(self, content_type="illust") -> ParsedJson: ...
# 小说推荐
def novel_recommended(self) -> ParsedJson: ...
# 作品排行
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
# date: '2016-08-01'
# mode (Past): [day, week, month, day_male, day_female, week_original, week_rookie,
# day_r18, day_male_r18, day_female_r18, week_r18, week_r18g]
def illust_ranking(self, mode="day", date=None) -> ParsedJson: ...
# 趋势标签 (Search - tags)
def trending_tags_illust(self) -> ParsedJson: ...
# 搜索 (Search)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# title_and_caption - 标题说明文
# sort: [date_desc, date_asc, popular_desc] - popular_desc为会员的热门排序
# duration: [within_last_day, within_last_week, within_last_month]
# start_date, end_date: '2020-07-01'
def search_illust(
self,
word: str,
search_target="partial_match_for_tags",
sort="date_desc",
duration=None,
start_date=None,
end_date=None,
) -> ParsedJson: ...
# 搜索小说 (Search Novel)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# text - 正文
# keyword - 关键词
# sort: [date_desc, date_asc]
# start_date/end_date: 2020-06-01
def search_novel(
self,
word: str,
search_target="partial_match_for_tags",
sort="date_desc",
start_date=None,
end_date=None,
) -> ParsedJson: ...
def search_user(self, word: str, sort='date_desc', duration=None) -> ParsedJson: ...
# 作品收藏详情
def illust_bookmark_detail(self, illust_id: int | str) -> ParsedJson: ...
# 新增收藏
def illust_bookmark_add(self, illust_id: int | str, restrict="public", tags=None) -> ParsedJson: ...
# 删除收藏
def illust_bookmark_delete(self, illust_id: int | str) -> ParsedJson: ...
# 关注用户
def user_follow_add(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# 取消关注用户
def user_follow_delete(self, user_id: int | str) -> ParsedJson: ...
# 用户收藏标签列表
def user_bookmark_tags_illust(self, restrict="public") -> ParsedJson: ...
# Following用户列表
def user_following(self, user_id: int | str, restrict="public") -> ParsedJson: ...
# Followers用户列表
def user_follower(self, user_id: int | str) -> ParsedJson: ...
# 好P友
def user_mypixiv(self, user_id: int | str) -> ParsedJson: ...
# 黑名单用户
def user_list(self, user_id: int | str) -> ParsedJson: ...
# 获取ugoira信息
def ugoira_metadata(self, illust_id: int | str) -> ParsedJson: ...
# 用户小说列表
def user_novels(self, user_id: int | str) -> ParsedJson: ...
# 小说系列详情
def novel_series(self, series_id: int | str, last_order=None) -> ParsedJson: ...
# 小说详情
def novel_detail(self, novel_id: int | str) -> ParsedJson: ...
# 小说 (包含正文)
def webview_novel(self, novel_id: int | str) -> ParsedJson: ...
# 小说评论
def novel_comments(self, novel_id: int | str) -> ParsedJson: ...
# 大家的新作
# content_type: [illust, manga]
def illust_new(self, content_type="illust", max_illust_id=None) -> ParsedJson: ...
def novel_new(self, max_novel_id=None) -> ParsedJson: ...
# 特辑详情 (无需登录,调用Web API)
def showcase_article(self, showcase_id) -> ParsedJson: ...
from pixivpy3 import AppPixivAPI
api = AppPixivAPI()
# 作品推荐
json_result = api.illust_recommended()
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 作品相关推荐
json_result = api.illust_related(57065990)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 作品相关推荐-下一页 (.parse_qs(next_url) 用法)
next_qs = api.parse_qs(json_result.next_url)
json_result = api.illust_related(**next_qs)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户详情
json_result = api.user_detail(660788)
print(json_result)
user = json_result.user
print(f"{user.name}(@{user.account}) region={json_result.profile.region}")
# 用户作品列表
json_result = api.user_illusts(660788)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户收藏列表
json_result = api.user_bookmarks_illust(2088434)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户收藏列表中的小说
json_result = api.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(f">>> {novel.title}, text_length: {novel.text_length}, series: {novel.series}")
# 2016-07-15 日的过去一周排行
json_result = api.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 关注用户的新作 (需要login)
json_result = api.illust_follow(req_auth=True)
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 标签 "水着" 搜索
json_result = api.search_illust('水着', search_target='partial_match_for_tags')
print(json_result)
illust = json_result.illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 用户 "gomzi" 搜索
json_result = api.search_user("gomzi")
print(json_result)
illust = json_result.user_previews[0].illusts[0]
print(f">>> {illust.title}, origin url: {illust.image_urls.large}")
# 展示小说评论区
json_result = api.novel_comments(16509454, include_total_comments=True)
print(f"Total comments = {json_result.total_comments}")
for comment in json_result.comments:
if comment.parent_comment:
print(f"{comment.user.name} replied to {comment.parent_comment.user.name} at {comment.date} : {comment.comment}")
else:
print(f"{comment.user.name} at {comment.date} : {comment.comment}")
# Updating dependencies
$ poetry update --with=dev,test
Fork this project and create a new branch for your changes. Push your changes to your fork and create a pull request.
poetry run pytest
Follow these simple steps to publish your Poetry package. We recommend publishing to the test.pypi.org instance first, to verify everything is working as expected.
This step only has to be done once:
# Configure test.pypi.org
poetry config repositories.testpypi https://test.pypi.org/legacy/
# Configure API Keys for both PyPI and TestPyPY
poetry config pypi-token.testpypi <testpypi_api_key>
poetry config pypi-token.pypi <pypi_api_key>
Now publish the new version:
# Adjust the package version at the top of the "pyproject.toml" file
vim pyproject.toml
# Build python packages to dist/ folder
poetry build
# Publish package to TestPyPi
poetry publish -r testpypi
# Checkout published package in a different environment
pip install --index-url https://test.pypi.org/simple/ <your_package_name>
# Once confirmed that everything works, publish to the real PyPi
poetry publish
Feel free to use, reuse and abuse the code in this project.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
339 followers · starred Aug 2017
54 followers · starred May 2022
20 followers · starred Aug 2020
45 followers · starred Jan 2022