From 370e33aa3c8051d614df3b4f92dffa6373c5c4c1 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Sat, 6 Aug 2016 12:10:01 +0800 Subject: [PATCH] Add ranking demo for AppAPI, update README --- README.md | 12 ++++++++++++ demo.py | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.md b/README.md index 51d967c5..f300a7ba 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,12 @@ class AppPixivAPI(BasePixivAPI): # 用户收藏作品列表 (无需登录) def user_bookmarks_illust(self, user_id, restrict='public'): + # 作品排行 + # mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga] + # date: '2016-08-01' + # mode(r18榜单需登录): [day_r18, day_male_r18, day_female_r18, week_r18, week_r18g] + def illust_ranking(self, mode='day', date=None, offset=None): + # 关注用户的新作 # restrict: [public, private] def illust_follow(self, restrict='public'): @@ -152,6 +158,12 @@ print(json_result) illust = json_result.illusts[0] print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large'])) +# 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) diff --git a/demo.py b/demo.py index f758480c..0676564c 100644 --- a/demo.py +++ b/demo.py @@ -228,6 +228,25 @@ def appapi_search(aapi): illust = json_result.illusts[0] print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large'])) +def appapi_ranking(aapi): + json_result = aapi.illust_ranking('day_male') + print(json_result) + illust = json_result.illusts[0] + print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large'])) + + # get next page + next_qs = aapi.parse_qs(json_result.next_url) + json_result = aapi.illust_ranking(**next_qs) + # print(json_result) + illust = json_result.illusts[0] + print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large'])) + + # 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'])) + def appapi_auth_api(aapi): json_result = aapi.illust_follow(req_auth=True) print(json_result) @@ -269,6 +288,7 @@ def main(): appapi_recommend(aapi) appapi_users(aapi) appapi_search(aapi) + appapi_ranking(aapi) # auth test aapi.login(_USERNAME, _PASSWORD)