forked from upbit/pixivpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_bypass_sni.py
More file actions
43 lines (31 loc) · 1.09 KB
/
Copy pathexample_bypass_sni.py
File metadata and controls
43 lines (31 loc) · 1.09 KB
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
# -*- coding: utf-8 -*-
import sys
from datetime import datetime, timedelta
from pixivpy3 import ByPassSniApi
sys.dont_write_bytecode = True
# get your refresh_token, and replace _REFRESH_TOKEN
# https://github.com/upbit/pixivpy/issues/158#issuecomment-778919084
_REFRESH_TOKEN = "0zeYA-PllRYp1tfrsq_w3vHGU1rPy237JMf5oDt73c4"
def main():
api = ByPassSniApi() # Same as AppPixivAPI, but bypass the GFW
api.require_appapi_hosts()
# api.set_additional_headers({'Accept-Language':'en-US'})
api.set_accept_language("en-us")
# api.login(_USERNAME, _PASSWORD)
print(api.auth(refresh_token=_REFRESH_TOKEN))
json_result = api.illust_ranking(
"day", date=(datetime.now() - timedelta(days=5)).strftime("%Y-%m-%d")
)
print(
"Printing image titles and tags with English tag translations present when available"
)
for illust in json_result.illusts[:3]:
print(
'Illustration: "'
+ str(illust.title)
+ '"\nTags: '
+ str(illust.tags)
+ "\n"
)
if __name__ == "__main__":
main()