remove lfs
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:249b62caa7922fecea19e69989bb1ff7259cc37d6ce4ee78fb16abce6acb6720
|
||||
size 7066775
|
Binary file not shown.
Binary file not shown.
104
pinyin/gen.py
104
pinyin/gen.py
@ -1,53 +1,53 @@
|
||||
t='''毕思淼
|
||||
毕一聪
|
||||
丛金旺
|
||||
崔子豪
|
||||
樊乐天
|
||||
高镆
|
||||
黄卓琳
|
||||
姜樱楠
|
||||
焦祺
|
||||
李柏畅
|
||||
李南卓阳
|
||||
李善伊
|
||||
李怡萱
|
||||
李语恒
|
||||
刘宇航
|
||||
刘雨鑫
|
||||
刘卓
|
||||
娄晴
|
||||
洛艺伟
|
||||
马卉冉
|
||||
潘一鸣
|
||||
庞惠铭
|
||||
乔旺源
|
||||
沈洁
|
||||
宋佳怡
|
||||
宋雨蔓
|
||||
宋智宪
|
||||
苏振宇
|
||||
王梁宇
|
||||
王明仁
|
||||
王耀增
|
||||
王子来
|
||||
吴庆波
|
||||
徐子灏
|
||||
阎展博
|
||||
杨颜聪
|
||||
于诗澳
|
||||
于世函
|
||||
张濠亿
|
||||
张日昊
|
||||
张姝肜
|
||||
张文桦
|
||||
张潇艺
|
||||
张晓轩
|
||||
张妍
|
||||
周含笑
|
||||
周巧冉'''
|
||||
from pypinyin import pinyin
|
||||
from pypinyin import Style
|
||||
l=t.splitlines()
|
||||
for text in l:
|
||||
tem=pinyin(text,style=Style.FIRST_LETTER)
|
||||
t='''毕思淼
|
||||
毕一聪
|
||||
丛金旺
|
||||
崔子豪
|
||||
樊乐天
|
||||
高镆
|
||||
黄卓琳
|
||||
姜樱楠
|
||||
焦祺
|
||||
李柏畅
|
||||
李南卓阳
|
||||
李善伊
|
||||
李怡萱
|
||||
李语恒
|
||||
刘宇航
|
||||
刘雨鑫
|
||||
刘卓
|
||||
娄晴
|
||||
洛艺伟
|
||||
马卉冉
|
||||
潘一鸣
|
||||
庞惠铭
|
||||
乔旺源
|
||||
沈洁
|
||||
宋佳怡
|
||||
宋雨蔓
|
||||
宋智宪
|
||||
苏振宇
|
||||
王梁宇
|
||||
王明仁
|
||||
王耀增
|
||||
王子来
|
||||
吴庆波
|
||||
徐子灏
|
||||
阎展博
|
||||
杨颜聪
|
||||
于诗澳
|
||||
于世函
|
||||
张濠亿
|
||||
张日昊
|
||||
张姝肜
|
||||
张文桦
|
||||
张潇艺
|
||||
张晓轩
|
||||
张妍
|
||||
周含笑
|
||||
周巧冉'''
|
||||
from pypinyin import pinyin
|
||||
from pypinyin import Style
|
||||
l=t.splitlines()
|
||||
for text in l:
|
||||
tem=pinyin(text,style=Style.FIRST_LETTER)
|
||||
print(''.join([i[0] for i in tem]))
|
56
rand/main.py
56
rand/main.py
@ -1,29 +1,29 @@
|
||||
from random import randint
|
||||
|
||||
bgn,end=[int(i) for i in input("Option: Input random area(like 21-43): ").split("-")]
|
||||
obj=int(input("Option: Amount: "))
|
||||
repeat=input("Option: Allow repeat:\nAccept: T(true) (defalt), F(false)\n").lower()
|
||||
if repeat == "":
|
||||
repeat=True
|
||||
else:
|
||||
if repeat in ["t","true"]:
|
||||
repeat=True
|
||||
elif repeat in ["f","false"]:
|
||||
repeat=False
|
||||
else:
|
||||
input("Unsupported option.")
|
||||
l=[]
|
||||
if repeat:
|
||||
l=[randint(bgn,end) for i in range(obj)]
|
||||
else:
|
||||
i=0
|
||||
while len(l)<obj and i<500:
|
||||
t=randint(bgn,end)
|
||||
i+=1
|
||||
if t not in l:
|
||||
l.append(t)
|
||||
|
||||
print(l)
|
||||
for i in l[1:]:
|
||||
print(randint(bgn,end),end=", ")
|
||||
from random import randint
|
||||
|
||||
bgn,end=[int(i) for i in input("Option: Input random area(like 21-43): ").split("-")]
|
||||
obj=int(input("Option: Amount: "))
|
||||
repeat=input("Option: Allow repeat:\nAccept: T(true) (defalt), F(false)\n").lower()
|
||||
if repeat == "":
|
||||
repeat=True
|
||||
else:
|
||||
if repeat in ["t","true"]:
|
||||
repeat=True
|
||||
elif repeat in ["f","false"]:
|
||||
repeat=False
|
||||
else:
|
||||
input("Unsupported option.")
|
||||
l=[]
|
||||
if repeat:
|
||||
l=[randint(bgn,end) for i in range(obj)]
|
||||
else:
|
||||
i=0
|
||||
while len(l)<obj and i<500:
|
||||
t=randint(bgn,end)
|
||||
i+=1
|
||||
if t not in l:
|
||||
l.append(t)
|
||||
|
||||
print(l)
|
||||
for i in l[1:]:
|
||||
print(randint(bgn,end),end=", ")
|
||||
print(l[0])
|
206
recode/recode.py
206
recode/recode.py
@ -1,103 +1,103 @@
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir
|
||||
from os import mkdir
|
||||
from json import dump, load
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
Options:
|
||||
If options is specified, program will only save configs.
|
||||
|
||||
-i: input file code. (eg. utf-8) (Default: test all known codes)
|
||||
-o: output file code. (Default: utf-8)
|
||||
-c: codes that try to convert from. (Default: test all known codes)
|
||||
split by ','. (eg. utf-8,gbk,gb2312)
|
||||
-r: save the output file in the specified directory. (Default: out)
|
||||
-s: show all known codes. (Don't use this with others)
|
||||
'''
|
||||
OPTIONS = ["-i", "-o", "-c", "-s", "-r"]
|
||||
|
||||
CODES = ['ascii', 'big5', 'big5hkscs', 'cp037', 'cp273', 'cp424', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865', 'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006', 'cp1026', 'cp1125', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004',
|
||||
'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_8', 'iso8859_9', 'iso8859_10', 'iso8859_11', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_16', 'johab', 'koi8_r', 'koi8_t', 'koi8_u', 'kz1048', 'mac_cyrillic', 'mac_greek', 'mac_iceland', 'mac_latin2', 'mac_roman', 'mac_turkish', 'ptcp154', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213', 'utf_32', 'utf_32_be', 'utf_32_le', 'utf_16', 'utf_16_be', 'utf_16_le', 'utf_7', 'utf_8', 'utf_8_sig']
|
||||
DEFALT = {'ipt': None, 'opt': 'utf-8', 'test': None, 'write': 'out'}
|
||||
|
||||
|
||||
def setOption(arg):
|
||||
if arg[0] == '-s':
|
||||
for i in CODES:
|
||||
print("%15s" % i, end=' ')
|
||||
return
|
||||
opt = arg[::2]
|
||||
val = arg[1:][::2]
|
||||
option = DEFALT.copy()
|
||||
trans = {'-i': 'ipt', '-o': 'opt', '-c': 'test', "-r": "write"}
|
||||
for o, v in zip(opt, val):
|
||||
if o == '-c':
|
||||
option[trans[o]] = v.split(',')
|
||||
else:
|
||||
option[trans[o]] = v
|
||||
with open("config.json", "w") as f:
|
||||
dump(option, f)
|
||||
|
||||
|
||||
def main(files):
|
||||
if isfile("config.json"):
|
||||
try:
|
||||
with open("config.json", "r") as f:
|
||||
config = load(f)
|
||||
except Exception:
|
||||
print("Can't read config file.")
|
||||
config = DEFALT
|
||||
else:
|
||||
print("No config file provided.")
|
||||
config = DEFALT
|
||||
|
||||
codes = CODES if config["test"] is None else config["test"]
|
||||
outcode = config["opt"]
|
||||
outdir = config["write"]
|
||||
|
||||
if not isdir(outdir):
|
||||
mkdir(outdir)
|
||||
|
||||
for file in files:
|
||||
if isfile(outdir+'/'+file):
|
||||
print(f"File '{outdir+'/'+file} exists. Ignore.")
|
||||
continue
|
||||
if config["ipt"] is None:
|
||||
for code in codes:
|
||||
if recode(file, outdir, code, outcode, config["write"]):
|
||||
break
|
||||
else:
|
||||
if not recode(file, outdir, config["ipt"], outcode):
|
||||
print("Could not convert '%s' from '%s' to '%s'" %
|
||||
(file, config["ipt"], outcode))
|
||||
else:
|
||||
print(f"Success to convert {file}")
|
||||
|
||||
|
||||
def recode(file, opt, src, to) -> bool:
|
||||
try:
|
||||
with open(file, 'r', encoding=src) as f:
|
||||
tem = f.read()
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't open file.")
|
||||
return False
|
||||
try:
|
||||
with open(opt+'/'+file, 'w', encoding=to) as f:
|
||||
f.write(tem)
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't write file.")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
exit(1)
|
||||
elif argv[1] in OPTIONS:
|
||||
setOption(argv[1:])
|
||||
else:
|
||||
main(argv[1:])
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir
|
||||
from os import mkdir
|
||||
from json import dump, load
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
Options:
|
||||
If options is specified, program will only save configs.
|
||||
|
||||
-i: input file code. (eg. utf-8) (Default: test all known codes)
|
||||
-o: output file code. (Default: utf-8)
|
||||
-c: codes that try to convert from. (Default: test all known codes)
|
||||
split by ','. (eg. utf-8,gbk,gb2312)
|
||||
-r: save the output file in the specified directory. (Default: out)
|
||||
-s: show all known codes. (Don't use this with others)
|
||||
'''
|
||||
OPTIONS = ["-i", "-o", "-c", "-s", "-r"]
|
||||
|
||||
CODES = ['ascii', 'big5', 'big5hkscs', 'cp037', 'cp273', 'cp424', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865', 'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006', 'cp1026', 'cp1125', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004',
|
||||
'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_8', 'iso8859_9', 'iso8859_10', 'iso8859_11', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_16', 'johab', 'koi8_r', 'koi8_t', 'koi8_u', 'kz1048', 'mac_cyrillic', 'mac_greek', 'mac_iceland', 'mac_latin2', 'mac_roman', 'mac_turkish', 'ptcp154', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213', 'utf_32', 'utf_32_be', 'utf_32_le', 'utf_16', 'utf_16_be', 'utf_16_le', 'utf_7', 'utf_8', 'utf_8_sig']
|
||||
DEFALT = {'ipt': None, 'opt': 'utf-8', 'test': None, 'write': 'out'}
|
||||
|
||||
|
||||
def setOption(arg):
|
||||
if arg[0] == '-s':
|
||||
for i in CODES:
|
||||
print("%15s" % i, end=' ')
|
||||
return
|
||||
opt = arg[::2]
|
||||
val = arg[1:][::2]
|
||||
option = DEFALT.copy()
|
||||
trans = {'-i': 'ipt', '-o': 'opt', '-c': 'test', "-r": "write"}
|
||||
for o, v in zip(opt, val):
|
||||
if o == '-c':
|
||||
option[trans[o]] = v.split(',')
|
||||
else:
|
||||
option[trans[o]] = v
|
||||
with open("config.json", "w") as f:
|
||||
dump(option, f)
|
||||
|
||||
|
||||
def main(files):
|
||||
if isfile("config.json"):
|
||||
try:
|
||||
with open("config.json", "r") as f:
|
||||
config = load(f)
|
||||
except Exception:
|
||||
print("Can't read config file.")
|
||||
config = DEFALT
|
||||
else:
|
||||
print("No config file provided.")
|
||||
config = DEFALT
|
||||
|
||||
codes = CODES if config["test"] is None else config["test"]
|
||||
outcode = config["opt"]
|
||||
outdir = config["write"]
|
||||
|
||||
if not isdir(outdir):
|
||||
mkdir(outdir)
|
||||
|
||||
for file in files:
|
||||
if isfile(outdir+'/'+file):
|
||||
print(f"File '{outdir+'/'+file} exists. Ignore.")
|
||||
continue
|
||||
if config["ipt"] is None:
|
||||
for code in codes:
|
||||
if recode(file, outdir, code, outcode, config["write"]):
|
||||
break
|
||||
else:
|
||||
if not recode(file, outdir, config["ipt"], outcode):
|
||||
print("Could not convert '%s' from '%s' to '%s'" %
|
||||
(file, config["ipt"], outcode))
|
||||
else:
|
||||
print(f"Success to convert {file}")
|
||||
|
||||
|
||||
def recode(file, opt, src, to) -> bool:
|
||||
try:
|
||||
with open(file, 'r', encoding=src) as f:
|
||||
tem = f.read()
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't open file.")
|
||||
return False
|
||||
try:
|
||||
with open(opt+'/'+file, 'w', encoding=to) as f:
|
||||
f.write(tem)
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't write file.")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
exit(1)
|
||||
elif argv[1] in OPTIONS:
|
||||
setOption(argv[1:])
|
||||
else:
|
||||
main(argv[1:])
|
||||
|
@ -1,58 +1,58 @@
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir,abspath
|
||||
from os import mkdir
|
||||
from chardet import detect
|
||||
from colorama import init,Fore
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
'''
|
||||
TARGET = 'utf-8'
|
||||
OUTDIR = "Output"
|
||||
|
||||
|
||||
def main(files):
|
||||
if not isdir(OUTDIR):
|
||||
mkdir(OUTDIR)
|
||||
|
||||
for file in files:
|
||||
path = abspath(file)
|
||||
path = path.replace("\\", "/")
|
||||
path = path.split('/')
|
||||
path = '/'.join(path[:-1])+"/"+OUTDIR+"/"+path[-1]
|
||||
if isfile(path):
|
||||
print(Fore.YELLOW+f"WARN: File '{path} exists. Ignore.")
|
||||
continue
|
||||
recode(file,path)
|
||||
|
||||
|
||||
def recode(file,path):
|
||||
try:
|
||||
with open(file, 'rb') as f:
|
||||
tem = f.read()
|
||||
except Exception as e:
|
||||
print(Fore.RED+f"ERROR: Can't open file '{file}'")
|
||||
return
|
||||
ret = detect(tem)
|
||||
if ret["encoding"] is None:
|
||||
print(Fore.RED+"ERROR: Cannot detect encoding of `%s`" % file)
|
||||
return
|
||||
|
||||
with open(file, 'r',encoding=ret["encoding"]) as f:
|
||||
tem = f.read()
|
||||
|
||||
if ret['confidence'] < 0.8:
|
||||
print(Fore.YELLOW+"WARN: File `%s` confidence is lower than 0.8. Recognized as `%s`."%(file,ret["encoding"]))
|
||||
|
||||
with open(path, 'w', encoding=TARGET) as f:
|
||||
f.write(tem)
|
||||
print(Fore.LIGHTBLUE_EX+"INFO: Success for `%s` with confidence %0.1f%%"%(file,ret["confidence"]*100))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init(autoreset=True)
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
else:
|
||||
main(argv[1:])
|
||||
print("------------------------")
|
||||
input("Press enter to exit")
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir,abspath
|
||||
from os import mkdir
|
||||
from chardet import detect
|
||||
from colorama import init,Fore
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
'''
|
||||
TARGET = 'utf-8'
|
||||
OUTDIR = "Output"
|
||||
|
||||
|
||||
def main(files):
|
||||
if not isdir(OUTDIR):
|
||||
mkdir(OUTDIR)
|
||||
|
||||
for file in files:
|
||||
path = abspath(file)
|
||||
path = path.replace("\\", "/")
|
||||
path = path.split('/')
|
||||
path = '/'.join(path[:-1])+"/"+OUTDIR+"/"+path[-1]
|
||||
if isfile(path):
|
||||
print(Fore.YELLOW+f"WARN: File '{path} exists. Ignore.")
|
||||
continue
|
||||
recode(file,path)
|
||||
|
||||
|
||||
def recode(file,path):
|
||||
try:
|
||||
with open(file, 'rb') as f:
|
||||
tem = f.read()
|
||||
except Exception as e:
|
||||
print(Fore.RED+f"ERROR: Can't open file '{file}'")
|
||||
return
|
||||
ret = detect(tem)
|
||||
if ret["encoding"] is None:
|
||||
print(Fore.RED+"ERROR: Cannot detect encoding of `%s`" % file)
|
||||
return
|
||||
|
||||
with open(file, 'r',encoding=ret["encoding"]) as f:
|
||||
tem = f.read()
|
||||
|
||||
if ret['confidence'] < 0.8:
|
||||
print(Fore.YELLOW+"WARN: File `%s` confidence is lower than 0.8. Recognized as `%s`."%(file,ret["encoding"]))
|
||||
|
||||
with open(path, 'w', encoding=TARGET) as f:
|
||||
f.write(tem)
|
||||
print(Fore.LIGHTBLUE_EX+"INFO: Success for `%s` with confidence %0.1f%%"%(file,ret["confidence"]*100))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init(autoreset=True)
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
else:
|
||||
main(argv[1:])
|
||||
print("------------------------")
|
||||
input("Press enter to exit")
|
||||
|
Binary file not shown.
62
video/cut.py
62
video/cut.py
@ -1,32 +1,32 @@
|
||||
from sys import argv
|
||||
from subprocess import run
|
||||
from os import system
|
||||
|
||||
if len(argv) != 2:
|
||||
print("Usage: <file>")
|
||||
exit(1)
|
||||
file = argv[1]
|
||||
tem=file.split(".")
|
||||
name = ".".join(tem[:-1])
|
||||
o = tem[-1]
|
||||
bgn = input("bgn: ")
|
||||
if bgn=="":
|
||||
bgn="0"
|
||||
to = input("to: ")
|
||||
cmd = [
|
||||
r'E:\green\ffmpeg\bin\ffmpeg.exe',
|
||||
'-i',
|
||||
file,
|
||||
'-ss',
|
||||
bgn,
|
||||
'-to',
|
||||
to,
|
||||
'-c',
|
||||
'copy',
|
||||
name+"_cut."+o
|
||||
]
|
||||
print(cmd)
|
||||
# run("pause")
|
||||
ret = run(cmd)
|
||||
print("ffmpeg finished with code",ret.returncode)
|
||||
from sys import argv
|
||||
from subprocess import run
|
||||
from os import system
|
||||
|
||||
if len(argv) != 2:
|
||||
print("Usage: <file>")
|
||||
exit(1)
|
||||
file = argv[1]
|
||||
tem=file.split(".")
|
||||
name = ".".join(tem[:-1])
|
||||
o = tem[-1]
|
||||
bgn = input("bgn: ")
|
||||
if bgn=="":
|
||||
bgn="0"
|
||||
to = input("to: ")
|
||||
cmd = [
|
||||
r'E:\green\ffmpeg\bin\ffmpeg.exe',
|
||||
'-i',
|
||||
file,
|
||||
'-ss',
|
||||
bgn,
|
||||
'-to',
|
||||
to,
|
||||
'-c',
|
||||
'copy',
|
||||
name+"_cut."+o
|
||||
]
|
||||
print(cmd)
|
||||
# run("pause")
|
||||
ret = run(cmd)
|
||||
print("ffmpeg finished with code",ret.returncode)
|
||||
system("pause")
|
148
wjx/main.py
148
wjx/main.py
@ -1,75 +1,75 @@
|
||||
from requests import Response,Session
|
||||
from re import search
|
||||
from json import dumps
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
s=Session()
|
||||
|
||||
def chk(resp:Response):
|
||||
if resp.status_code != 200:
|
||||
print("Error: %d" % resp.status_code)
|
||||
exit(1)
|
||||
return resp.text
|
||||
|
||||
def get(url,**kwargs):
|
||||
ret = s.get(url,allow_redirects=False,headers=headers,**kwargs)
|
||||
jar = ret.cookies
|
||||
if ret.status_code == 302:
|
||||
url2 = ret.headers['Location']
|
||||
return get(url2, cookies=jar)
|
||||
elif ret.status_code != 200:
|
||||
print("Error: %d" % ret.status_code)
|
||||
exit(1)
|
||||
return ret
|
||||
|
||||
def login(username, password):
|
||||
# 问卷星竟然明文发送密码
|
||||
ret = chk(s.get("https://www.wjx.cn/login.aspx"))
|
||||
v1 = search('(?<=(<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value=")).+(?=(" />))',ret)
|
||||
if v1 is not None:
|
||||
v1 = v1.group()
|
||||
v2 = search('(?<=(<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value=")).+(?=(" />))',ret)
|
||||
if v2 is not None:
|
||||
v2 = v2.group()
|
||||
v3 = search('(?<=(<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value=")).+(?=(" />))',ret)
|
||||
if v3 is not None:
|
||||
v3 = v3.group()
|
||||
print(v1,v2,v3)
|
||||
with open("tmp.html", "w",encoding="utf-8") as f:
|
||||
print(ret,file=f)
|
||||
d={
|
||||
"__VIEWSTATE": v1,
|
||||
"__VIEWSTATEGENERATOR": v2,
|
||||
"__EVENTVALIDATION": v3,
|
||||
"UserName": username,
|
||||
"Password": password,
|
||||
"LoginButton": "登录"
|
||||
}
|
||||
# d={
|
||||
# "__VIEWSTATE": "/wEPDwULLTIxMTQ1NzY4NzFkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQpSZW1lbWJlck1ldLwU4qgz33Rji8zou8eAENNib4k=",
|
||||
# "__VIEWSTATEGENERATOR":"C2EE9ABB",
|
||||
# "__EVENTVALIDATION": "/wEdAAfxrqR6nVOy3mBYlwdwNQ3ZR1LBKX1P1xh290RQyTesRRHS0B3lkDg8wcTlzQR027xRgZ0GCHKgt6QG86UlMSuIXArz/WCefbk6V2VE3Ih52ScdcjStD50aK/ZrfWs/uQXcqaj6i4HaaYTcyD0yJuxuNMxKZaXzJnI0VXVv9OL2HZrk5tk=",
|
||||
# "UserName": username,
|
||||
# "Password": password,
|
||||
# "LoginButton": "登录"
|
||||
# }
|
||||
ret = s.post("https://www.wjx.cn/Login.aspx",json=dumps(d))
|
||||
ret.raise_for_status()
|
||||
|
||||
def getlist(id):
|
||||
ret = s.get(
|
||||
"https://www.wjx.cn/wjx/activitystat/viewstatsummary.aspx",
|
||||
params={"activity":id},
|
||||
headers=headers
|
||||
)
|
||||
ret = chk(ret)
|
||||
find = search(r'(?<=(var ids = "))[\d,]+(?=(";))',ret)
|
||||
assert find is not None,ret
|
||||
return find.group().split(",")
|
||||
|
||||
if __name__ == "__main__":
|
||||
login("flt","**************")
|
||||
print(s.cookies)
|
||||
from requests import Response,Session
|
||||
from re import search
|
||||
from json import dumps
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
s=Session()
|
||||
|
||||
def chk(resp:Response):
|
||||
if resp.status_code != 200:
|
||||
print("Error: %d" % resp.status_code)
|
||||
exit(1)
|
||||
return resp.text
|
||||
|
||||
def get(url,**kwargs):
|
||||
ret = s.get(url,allow_redirects=False,headers=headers,**kwargs)
|
||||
jar = ret.cookies
|
||||
if ret.status_code == 302:
|
||||
url2 = ret.headers['Location']
|
||||
return get(url2, cookies=jar)
|
||||
elif ret.status_code != 200:
|
||||
print("Error: %d" % ret.status_code)
|
||||
exit(1)
|
||||
return ret
|
||||
|
||||
def login(username, password):
|
||||
# 问卷星竟然明文发送密码
|
||||
ret = chk(s.get("https://www.wjx.cn/login.aspx"))
|
||||
v1 = search('(?<=(<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value=")).+(?=(" />))',ret)
|
||||
if v1 is not None:
|
||||
v1 = v1.group()
|
||||
v2 = search('(?<=(<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value=")).+(?=(" />))',ret)
|
||||
if v2 is not None:
|
||||
v2 = v2.group()
|
||||
v3 = search('(?<=(<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value=")).+(?=(" />))',ret)
|
||||
if v3 is not None:
|
||||
v3 = v3.group()
|
||||
print(v1,v2,v3)
|
||||
with open("tmp.html", "w",encoding="utf-8") as f:
|
||||
print(ret,file=f)
|
||||
d={
|
||||
"__VIEWSTATE": v1,
|
||||
"__VIEWSTATEGENERATOR": v2,
|
||||
"__EVENTVALIDATION": v3,
|
||||
"UserName": username,
|
||||
"Password": password,
|
||||
"LoginButton": "登录"
|
||||
}
|
||||
# d={
|
||||
# "__VIEWSTATE": "/wEPDwULLTIxMTQ1NzY4NzFkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQpSZW1lbWJlck1ldLwU4qgz33Rji8zou8eAENNib4k=",
|
||||
# "__VIEWSTATEGENERATOR":"C2EE9ABB",
|
||||
# "__EVENTVALIDATION": "/wEdAAfxrqR6nVOy3mBYlwdwNQ3ZR1LBKX1P1xh290RQyTesRRHS0B3lkDg8wcTlzQR027xRgZ0GCHKgt6QG86UlMSuIXArz/WCefbk6V2VE3Ih52ScdcjStD50aK/ZrfWs/uQXcqaj6i4HaaYTcyD0yJuxuNMxKZaXzJnI0VXVv9OL2HZrk5tk=",
|
||||
# "UserName": username,
|
||||
# "Password": password,
|
||||
# "LoginButton": "登录"
|
||||
# }
|
||||
ret = s.post("https://www.wjx.cn/Login.aspx",json=dumps(d))
|
||||
ret.raise_for_status()
|
||||
|
||||
def getlist(id):
|
||||
ret = s.get(
|
||||
"https://www.wjx.cn/wjx/activitystat/viewstatsummary.aspx",
|
||||
params={"activity":id},
|
||||
headers=headers
|
||||
)
|
||||
ret = chk(ret)
|
||||
find = search(r'(?<=(var ids = "))[\d,]+(?=(";))',ret)
|
||||
assert find is not None,ret
|
||||
return find.group().split(",")
|
||||
|
||||
if __name__ == "__main__":
|
||||
login("flt","**************")
|
||||
print(s.cookies)
|
||||
print(getlist("184412487"))
|
22
wjx/tmp.py
22
wjx/tmp.py
@ -1,12 +1,12 @@
|
||||
import requests
|
||||
|
||||
url = "https://www.wjx.cn/login.aspx"
|
||||
|
||||
payload={}
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
|
||||
import requests
|
||||
|
||||
url = "https://www.wjx.cn/login.aspx"
|
||||
|
||||
payload={}
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
4
zxxk_dl/.gitignore
vendored
4
zxxk_dl/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
*.html
|
||||
*.pdf
|
||||
*.html
|
||||
*.pdf
|
||||
*.docx
|
Reference in New Issue
Block a user