forked from gys619/Thread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jdCookie.py
executable file
·48 lines (43 loc) · 1.66 KB
/
jdCookie.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2022/7/6 23:00
# @Author : HarbourJ
# @TG : https://t.me/HarbourToulu
# @File : jdCookie.py
import os
import time
from functools import partial
print = partial(print, flush=True)
def get_cookies():
CookieJDs = []
if os.environ.get("JD_COOKIE"):
print("已获取并使用Env环境 Cookie")
if '&' in os.environ["JD_COOKIE"]:
CookieJDs = os.environ["JD_COOKIE"].split('&')
elif '\n' in os.environ["JD_COOKIE"]:
CookieJDs = os.environ["JD_COOKIE"].split('\n')
else:
CookieJDs = [os.environ["JD_COOKIE"]]
# return CookieJDs
else:
if os.path.exists("JD_COOKIE.txt"):
with open("JD_COOKIE.txt", 'r') as f:
JD_COOKIEs = f.read().strip()
if JD_COOKIEs:
if '&' in JD_COOKIEs:
CookieJDs = JD_COOKIEs.split('&')
elif '\n' in JD_COOKIEs:
CookieJDs = JD_COOKIEs.split('\n')
else:
CookieJDs = [JD_COOKIEs]
CookieJDs = sorted(set(CookieJDs), key=CookieJDs.index)
# return CookieJDs
else:
print("未获取到正确✅格式的京东账号Cookie")
return
print(f"====================共{len(CookieJDs)}个京东账号Cookie=========\n")
print(f"==================脚本执行- 北京时间(UTC+8):{time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())}=====================\n")
return CookieJDs
# if __name__ == "__main__":
# get_cookies()
# print(os.environ.get("JD_COOKIE"))