-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathexample_bypass_sni.py
40 lines (29 loc) · 1.03 KB
/
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
32
33
34
35
36
37
38
39
40
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 = "<your_refresh_token>"
def main() -> None:
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))
date = datetime.now() - timedelta(days=5)
json_result = api.illust_ranking("day", date=date)
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()