Former-commit-id: 8d2717060dc7314535a6422433dab9027b830b4f
Former-commit-id: 159f1cb3ea98a03db9bfad177cdf25b5b953b10a
This commit is contained in:
2022-09-23 10:29:05 +08:00
parent 849f29e160
commit 606861b3a1
5 changed files with 247 additions and 0 deletions

53
pinyin/gen.py Normal file
View File

@ -0,0 +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)
print(''.join([i[0] for i in tem]))

29
rand/main.py Normal file
View File

@ -0,0 +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=", ")
print(l[0])

58
recode/recode_new.py Normal file
View File

@ -0,0 +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")

32
video/cut.py Normal file
View File

@ -0,0 +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)
system("pause")

75
wjx/main.py Normal file
View File

@ -0,0 +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","***REMOVED***")
print(s.cookies)
print(getlist("184412487"))