Due to #158 reason, password login no longer exist. Please use
api.auth(refresh_token=REFRESH_TOKEN)
insteadTo get
refresh_token
, see @ZipFile Pixiv OAuth Flow or OAuth with Selenium/ChromeDriver
Pixiv API for Python (with Auth supported)
novel_text()
BUG, add webview_novel()
, seenovel_follow()
, fix ByPassSniApi() host BUG, seeillust_new
for get latest works, seefollow/unfollow
, add novel
API, seesearch_illust()
(thanksAppPixivAPI().search_novel()
for novel searchX-Client-Time/X-Client-Hash
(thanksillust_bookmark_add()/illust_bookmark_delete()
params (thanksPixivAPI().works()
liked API illust_detail()
for App-APIAppPixivAPI()
can call without auth (thanksPixivIOSApp/6.0.9
Use 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 *
api = AppPixivAPI()
# api.login("username", "password") # Not required
# get origin url
json_result = api.illust_detail(59580629)
illust = json_result.illust
print(">>> origin url: %s" % 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(" p1 [%s] %s" % (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(" p2 [%s] %s" % (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("[%s] %s" % (illust.title, illust.image_urls.medium))
next_qs = api.parse_qs(json_result.next_url)
pip install pixivpy --upgrade
api.download()
like the below:aapi = AppPixivAPI()
json_result = aapi.illust_ranking()
for illust in json_result.illusts[:3]:
aapi.download(illust.image_urls.large)
api.papi.*
to api.*
print(">>> new ranking_all(mode='daily', page=1, per_page=50)")
#rank_list = api.sapi.ranking("all", 'day', 1)
rank_list = api.ranking_all('daily', 1, 50)
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("[%s/%s(id=%s)] %s" % (img.work.user.name, img.work.title, img.work.id, img.work.image_urls.px_480mw))
If you have any questions, please feel free to contact me: [email protected]
Find Pixiv API in Objective-C? You might also like PixivAPI_iOS
class AppPixivAPI(BasePixivAPI):
#
def parse_qs(next_url):
#
def user_detail(user_id):
#
## type: [illust, manga]
def user_illusts(user_id, type="illust"):
#
# tag: user_bookmark_tags_illust
def user_bookmarks_illust(user_id, restrict="public"):
#
def user_bookmarks_novel(user_id, restrict="public"):
def user_related(seed_user_id):
#
# restrict: [public, private]
def illust_follow(restrict="public"):
# (PAPI.works()iOS)
def illust_detail(illust_id):
#
def illust_comments(illust_id, include_total_comments=None):
#
def illust_related(illust_id):
# (Home - Main)
# content_type: [illust, manga]
def illust_recommended(content_type="illust"):
#
def novel_recommended():
#
# 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(mode="day", date=None):
# (Search - tags)
def trending_tags_illust():
# (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(word, search_target="partial_match_for_tags", sort="date_desc", duration=None, start_date=None, end_date=None):
# (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(word, search_target="partial_match_for_tags", sort="date_desc", start_date=None, end_date=None):
def search_user(word, sort='date_desc', duration=None):
#
def illust_bookmark_detail(illust_id):
#
def illust_bookmark_add(illust_id, restrict="public", tags=None):
#
def illust_bookmark_delete(illust_id):
#
def user_follow_add(user_id, restrict="public"):
#
def user_follow_delete(user_id):
#
def user_bookmark_tags_illust(restrict="public"):
# Following
def user_following(user_id, restrict="public"):
# Followers
def user_follower(user_id):
# P
def user_mypixiv(user_id):
#
def user_list(user_id):
# ugoira
def ugoira_metadata(illust_id):
#
def user_novels(user_id):
#
def novel_series(series_id, last_order=None):
#
def novel_detail(novel_id):
# ()
def webview_novel(novel_id):
#
def novel_comments(novel_id):
#
# content_type: [illust, manga]
def illust_new(content_type="illust", max_illust_id=None):
def novel_new(max_novel_id=None):
# (Web API)
def showcase_article(showcase_id):
aapi = AppPixivAPI()
#
json_result = aapi.illust_recommended()
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
#
json_result = aapi.illust_related(57065990)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# - (.parse_qs(next_url) )
next_qs = aapi.parse_qs(json_result.next_url)
json_result = aapi.illust_related(**next_qs)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
#
json_result = aapi.user_detail(660788)
print(json_result)
user = json_result.user
print("%s(@%s) region=%s" % (user.name, user.account, json_result.profile.region))
#
json_result = aapi.user_illusts(660788)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
#
json_result = aapi.user_bookmarks_illust(2088434)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
#
json_result = aapi.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(">>> {}, text_length: {}, series: {}".format(novel.title, novel.text_length, novel.series))
# 2016-07-15
json_result = aapi.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# (login)
json_result = aapi.illust_follow(req_auth=True)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# ""
json_result = aapi.search_illust('', search_target='partial_match_for_tags')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# "gomzi"
json_result = aapi.search_user("gomzi")
print(json_result)
illust = json_result.user_previews[0].illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
#
json_result = aapi.novel_comments(16509454, include_total_comments=True)
print("Total comments = {}".format(json_result["total_comments"]))
for comment in json_result["comments"]:
if comment["parent_comment"] != dict():
print("{user} replied to {target} at {time} : {content}".format(user = comment["user"]["name"], time = comment["date"], content = comment["comment"], target = comment["parent_comment"]["user"]["name"]))
else:
print("{user} at {time} : {content}".format(user=comment["user"]["name"], time=comment["date"], content=comment["comment"]))
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.