爬虫扇贝网英语测评页面
import requests
url = 'https://www.shanbay.com/api/v1/vocabtest/category/'
res = requests.get(url)
print(res)
json_res = res.json()
words_knows=[]
not_knows = []
words = {}
answers = {}
zw = 0
cw = 0
print('词库选择:')
num = 1
num2 = 1
for data in json_res['data']:
print(str(num) +'-'+data[1])
words[num] = data[0]
num += 1
print('请选择想测的词库,输入序号即可:')
while True:
try:
choose = int(input(''))
if 1<=choose<=10:
category = words[choose]
break
else:
print('请输入正确的词库序号:')
except ValueError:
print('请输入正确的词库序号:')
url2 = 'https://www.shanbay.com/api/v1/vocabtest/vocabularies/'
params = {'category': category }
res2 = requests.get(url2,params=params)
json_res2 = res2.json()
print('好的,接下来请你选择认识的单词:')
for word in json_res2['data']:
uword = word['content']
knows = input(uword+'--这个单词你认识吗?认识输入任意键,不认识直接回车:\n')
if knows != '':
words_knows.append(uword)
print('请选择【',uword,'】的正确词义:')
for answer in word['definition_choices']:
answers[num2] = [answer['pk'],answer['rank']]
print(str(num2),'-',answer['definition'])
num2+=1
print('5-不认识')
while True:
try:
chooses = int(input(''))
if 1<=chooses<=4:
if word['pk'] == answers[chooses][0] and word['rank'] == answers[chooses][1]:
print('回答正确')
zw +=1
else:
print('回答错误')
cw +=1
break
elif chooses == 5:
words_knows.remove(uword)
not_knows.append(uword)
break
else:
print('请输入正确的序号:')
except ValueError:
print('请输入正确的序号:')
else:
not_knows.append(uword)
num2 = 1
print('认识{}个单词,不认识{}个单词,掌握{}个,做错了{}个'.format(len(words_knows),len(not_knows),zw,cw))
© 版权声明
THE END
喜欢就支持以下吧
用户669866053年前0
bm自签没有文件下载青葱岁月3年前0
下载不下来,用不了_浅忘3年前0
好用的,嘿嘿望北丶3年前0
确实可以,一天30-40的样子