-
Notifications
You must be signed in to change notification settings - Fork 149
/
demo.py
85 lines (68 loc) · 2.35 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
sys.dont_write_bytecode = True
from pixivpy3 import *
### change _USERNAME,_PASSWORD first!
_USERNAME = "username"
_PASSWORD = "password"
def migrate_rev2_to_papi(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)
def papi_demo(api):
# PAPI.works
json_result = api.works(46363414)
print json_result
illust = json_result.response[0]
print ">>> %s, origin url: %s" % (illust.caption, illust.image_urls['large'])
# PAPI.users
json_result = api.users(1184799)
print json_result
user = json_result.response[0]
print user.profile.introduction
# PAPI.me_feeds
json_result = api.me_feeds(show_r18=0)
print json_result
ref_work = json_result.response[0].ref_work
print ref_work.title
# PAPI.users_works
json_result = api.users_works(1184799)
print json_result
illust = json_result.response[0]
print ">>> %s, origin url: %s" % (illust.caption, illust.image_urls['large'])
# PAPI.users_favorite_works
json_result = api.users_favorite_works(1184799)
print json_result
illust = json_result.response[0].work
print ">>> %s origin url: %s" % (illust.caption, illust.image_urls['large'])
# PAPI.ranking_all
json_result = api.ranking_all('weekly', 1)
print json_result
illust = json_result.response[0].works[0].work
print ">>> %s origin url: %s" % (illust.title, illust.image_urls['large'])
# PAPI.ranking_all(2015-05-01)
json_result = api.ranking_all(mode='daily', page=1, date='2015-05-01')
print json_result
illust = json_result.response[0].works[0].work
print ">>> %s origin url: %s" % (illust.title, illust.image_urls['large'])
# PAPI.search_works
json_result = api.search_works("水遊び", 1)
print json_result
illust = json_result.response[0]
print ">>> %s origin url: %s" % (illust.title, illust.image_urls['large'])
def main():
api = PixivAPI()
api.login(_USERNAME, _PASSWORD)
#migrate_rev2_to_papi(api)
papi_demo(api)
if __name__ == '__main__':
main()