学小易接口更新+新的接口+成品
之前有发一次源码,但是后面我自己账号被冻结,就没有继续看了,看论坛大佬们都更新了,我也重新发个我的版本本次更新:
1.增加一个联网提醒(用的是讯飞语记),如果出现大规模封号,我会更改为‘当前软件不可用’避免继续有人掉坑
2.增加了备用查题接口,用的是助课宝和另一个接口,助课宝用的是私人账号抓的接口,次数有限制,有能力的可以自己抓包替换参数
3.补全了学小易的headers参数,t应该是时间戳,没有设置定值,s和device值找不到加密方法,设个定值页勉强能用(增加了封号风险吧),具体看代码吧
4.本次发布成品
PS.本版本还是存在冻结风险,我之前冻结过的账号用了不一会就冻结了,但是之前没冻结过的账号能一直稳定,如果出现秒封,请回帖反馈
感谢支持,评分走一波?{:301_999:}
import tkinter as tk
from tkinter import ttk
import requests,os,urllib3,time,hashlib,json
fromlxml import etree
class PyWinDesign:
def __init__(self, 启动窗口):
self.启动窗口 = 启动窗口
self.启动窗口.title('学小易查题接口PC ——by 浅山藏')
self.启动窗口.resizable(width=True, height=True)
screenwidth = self.启动窗口.winfo_screenwidth()
screenheight = self.启动窗口.winfo_screenheight()
size = '%dx%d+%d+%d' % (596, 430, (screenwidth - 596) / 2, (screenheight - 430) / 2)
self.启动窗口.geometry(size)
self.标签1_标题 = tk.StringVar()
self.标签1_标题.set('账号:')
self.标签1 = tk.Label(self.启动窗口,textvariable=self.标签1_标题,anchor=tk.W)
self.标签1.place(x=380,y=19,width=35,height=25)
self.标签2_标题 = tk.StringVar()
self.标签2_标题.set('密码:')
self.标签2 = tk.Label(self.启动窗口,textvariable=self.标签2_标题,anchor=tk.W)
self.标签2.place(x=381,y=50,width=36,height=27)
self.编辑框1 = tk.Text(self.启动窗口,wrap=tk.NONE)
self.编辑框1.insert(tk.END,'')
self.编辑框1.place(x=438,y=19,width=150,height=25)
self.编辑框2_标题 = tk.StringVar()
self.编辑框2 =tk.Entry(self.启动窗口, textvariable=self.编辑框2_标题, show='*')
self.编辑框2.place(x=438,y=54,width=150,height=25)
self.按钮1_标题 = tk.StringVar()
self.按钮1_标题.set('登录')
self.按钮1 = tk.Button(self.启动窗口,textvariable=self.按钮1_标题,command=self.按钮1_被鼠标左键单击)
self.按钮1.place(x=483,y=90,width=56,height=41)
self.编辑框3 = tk.Text(self.启动窗口,wrap=tk.NONE)
self.编辑框3.insert(tk.END,'')
self.编辑框3.place(x=22,y=26,width=332,height=55)
self.按钮2_标题 = tk.StringVar()
self.按钮2_标题.set('查题')
self.按钮2 = tk.Button(self.启动窗口,textvariable=self.按钮2_标题,command=self.按钮2_被鼠标左键单击)
self.按钮2.place(x=40,y=92,width=80,height=40)
self.按钮3_标题 = tk.StringVar()
self.按钮3_标题.set('备用查题')
self.按钮3 = tk.Button(self.启动窗口,textvariable=self.按钮3_标题,command=self.按钮3_被鼠标左键单击)
self.按钮3.place(x=250,y=92,width=80,height=40)
self.编辑框4_滚动条_纵 = tk.Scrollbar(self.启动窗口)
self.编辑框4_滚动条_纵.place(x=568,y=147,width=18,height=275)
self.编辑框4 = tk.Text(self.启动窗口,yscrollcommand=self.编辑框4_滚动条_纵.set,wrap=tk.WORD)
self.编辑框4_滚动条_纵.config(command=self.编辑框4.yview)
self.编辑框4.insert(tk.END,'')
self.编辑框4.place(x=13,y=147,width=555,height=275)
url = 'http://www.iyuji.cn/iyuji/s/anZ1T2k2UG9Hak1FdHhmalZ5YmpiUT09/1593538728082638'
req = requests.get(url).text
html = etree.HTML(req)
txts = html.xpath('//*[@class="vp_text"]/p')
ti = ''
for txt in txts:
txt = txt.xpath('.//text()')
ti = ti + txt + '\n'
self.编辑框4.insert(tk.END,ti)
self.编辑框4.insert(tk.END,'\n')
if os.path.exists('.\\token.txt'):
self.编辑框4.insert(tk.END,'检测到token,无需登录,若查题失败请尝试重新登录\n本软件只调用接口,如若封号,概不负责\n备用查题无需登录,但题量可能较少\n——by 浅山藏')
f = open('token.txt')
global token
token = f.read()
else:
self.编辑框4.insert(tk.END,'请先用学小易账号密码进行登录\n本软件只调用接口,如若封号,概不负责\n备用查题无需登录,但题量可能较少\n——by 浅山藏')
def 按钮1_被鼠标左键单击(self):
self.编辑框4.delete('1.0','end')
user = self.编辑框1.get('0.0','end')
password = self.编辑框2.get()
url = 'https://app.51xuexiaoyi.com/api/v1/login'
data = {
'username':user,
'password':password
}
t_t = str(int(time.time()*1000))
headers ={
"Host":"app.51xuexiaoyi.com",
'device': 'Al5tmwTm9rTIOttQ3xHaJ00afNLO15wEkPnMUK3W_xce',
'platform': 'android',
'app-version': '1.0.6',
't':t_t,
's':'939aea07176a02feba86a1b277d9a129',
'Accept-Encoding': "gzip",
'User-Agent': 'okhttp/3.11.0'
}
req = requests.post(url,headers=headers,data=data,timeout=20).json()
code = req['code']
if code ==200:
self.编辑框4.delete('1.0','end')
self.编辑框4.insert(tk.END,'登录成功\n——by 浅山藏')
global token
token = req['data']['api_token']
f = open('token.txt','w')
f.write(token)
f.close()
else:
self.编辑框4.insert(tk.END,'登录失败,请检查账号密码重试\n——by 浅山藏')
def 按钮2_被鼠标左键单击(self):
try:
self.编辑框4.delete('1.0','end')
keyword = self.编辑框3.get('0.0','end')
url ='https://app.51xuexiaoyi.com/api/v1/searchQuestion'
global token
t_t = str(int(time.time()*1000))
headers = {
"Host":"app.51xuexiaoyi.com",
'token': token,
'device': 'Al5tmwTm9rTIOttQ3xHaJ00afNLO15wEkPnMUK3W_xce',
'platform': 'android',
'app-version': '1.0.6',
't':t_t,
's':'939aea07176a02feba86a1b277d9a129',
'Accept-Encoding': "gzip",
'User-Agent': 'okhttp/3.11.0'
}
data = {
"keyword":keyword
}
req = requests.post(url,headers=headers,data=data,timeout=20).json()
answers = ''
for i in range (0,len(req['data'])):
question = req['data']['q']
answer = req['data']['a']
answers = answers + '题目:'+question + '\n' +'答案:'+ answer +'\n\n'
self.编辑框4.insert(tk.END,answers)
except:
hui = req['msg']+'\n'+'如果您被封号,请不要再使用本版本,十分抱歉\n可以采用备用查题进行查题\n ——by.浅山藏'
self.编辑框4.insert(tk.END,hui)
def 按钮3_被鼠标左键单击(self):
try:
try:
self.编辑框4.delete('1.0','end')
keyword = self.编辑框3.get('0.0','end')
url = 'http://tiku.xuexibao.tech/api/mobile/Index/searchQuestion'
headers = {
'authorization':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vdGlrdS54dWV4aWJhby50ZWNoL2FwaS9tb2JpbGUvSW5kZXgvYXBwTG9naW4iLCJpYXQiOjE1OTM0Nzk4ODQsImV4cCI6MTkwODgzOTg4NCwibmJmIjoxNTkzNDc5ODg0LCJqdGkiOiI3TzFCVHkxT1VlWkNnaTFmIiwib3BlbklkIjoib1JFNXIxS001ejkyOFRQRXY5LXVTZm1nSkpXQSIsIndlY2hhdF9pZCI6Im9SRTVyMUtNNXo5MjhUUEV2OS11U2ZtZ0pKV0EiLCJ1bmlvbmlkIjoib3EySG8xWlJqOENUMmxsQlpONkNqbHJEZ19TSSIsImdvbmd6aG9uZyI6InpodWtlYmFvIn0.jzFyB7yrrFueRO-UkWPQKZqa4JPdXQZYA1KkwIQt5xg',
'appVersion':'1.0.7',
'osVersion':'10',
'jsVersion':'',
'appName':'??',
'deviceModel':'MI 8',
'deviceId':'',
'platform':'android',
'user-agent': 'MI 8(Android/10) (???/1.0.7) Weex/0.18.0 1080x2115',
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
'Host': 'tiku.xuexibao.tech',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip'
}
data = {
'goods_id':'6116',
'index':'0',
'content':keyword,
'sign':'6fc87ae8bd7b2cdd95ac3cbafe50885503ceceed'
}
req = requests.post(url,headers=headers,data=data,timeout=20).json()
answers = ''
for i in range (0,len(req['data'])):
question = req['data']['question']
answer = req['data']['answer']
answers = answers + '题目:'+question + '\n' +'答案:'+ answer +'\n\n'
self.编辑框4.insert(tk.END,'接口1:\n')
self.编辑框4.insert(tk.END,answers)
except:
self.编辑框4.insert(tk.END,'接口1:\n')
self.编辑框4.insert(tk.END,'查题失败\n')
##########接口二#########
try:
url = 'http://api.xmlm8.com/'
data = {
'w':keyword
}
req = requests.post(url,data=data,timeout=20)
html = etree.HTML(req.text)
t = html.xpath('/html/body/div/span/text()')
a = html.xpath('/html/body/div/span/text()')
answers = t + '\n' + a +'\n\n'
self.编辑框4.insert(tk.END,'接口2:\n')
self.编辑框4.insert(tk.END,answers)
except:
self.编辑框4.insert(tk.END,'接口2:\n')
except:
self.编辑框4.insert(tk.END,'查题失败,可能接口已失效')
if __name__ == '__main__':
root = tk.Tk()
root.attributes("-alpha",1)
root.attributes("-topmost", True)
app = PyWinDesign(root)
root.mainloop()
蓝奏云:https://wwa.lanzouj.com/ivwV5eajnzg 积木方块K 发表于 2020-7-15 22:32
备用接口能解决一部分问题,想着用本接口的特地去注册了一个账号,然后发现这里登不上,显示账号密码错误, ...
我刚刚试了一下,可以正常查的,要是显示密码错误,,可能真的是密码错了{:301_998:} 积木方块K 发表于 2020-7-15 22:32
备用接口能解决一部分问题,想着用本接口的特地去注册了一个账号,然后发现这里登不上,显示账号密码错误, ...
不排除其他原因吧,我还没遇到,具体不太清楚啊哈哈 每次都是自己顶{:301_973:} good.学小易挺好的 顶。学小易,对大学来说实在太友好了。不知道还有没有似乎没有其他能比的了 我的天,python变量名能用中文?!!! xccxvb 发表于 2020-7-4 12:13
我的天,python变量名能用中文?!!!
咳咳,我也不太懂,tkinter 是用论坛大佬发的一键生成插件做的,它生成就是中文 很好用!!!! treasure_s_ 发表于 2020-7-4 12:30
很好用!!!!
感谢支持啊哈 xccxvb 发表于 2020-7-4 12:13
我的天,python变量名能用中文?!!!
python3可以用中文 厉害了 学习学习