forked from upbit/pixivpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_bypass_sni.py
31 lines (20 loc) · 991 Bytes
/
example_bypass_sni.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
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()