代码拉取完成,页面将自动刷新
import requests
import json
import time
import os
def get_vocabulary(level_id: str):
body = {"id": level_id, "type": "builtin"}
response = requests.post(
"https://api.relingo.net/api/getVocabulary", json=body)
response.raise_for_status()
return response.json()
def process(level_id: str):
vocabulary = get_vocabulary(level_id)
if 'data' in vocabulary and 'words' in vocabulary['data']:
words = vocabulary['data']['words']
print(f'size of {level_id}: {len(words)}')
sorted_words = sorted(words)
# write json file in dated directory
cur_time = time.localtime()
date_named_dir = f'{cur_time.tm_year}-{cur_time.tm_mon}-{cur_time.tm_mday}'
if not os.path.exists(date_named_dir):
os.makedirs(date_named_dir)
with open(f'{date_named_dir}/level-{level_id}.json', 'w') as json_file:
json.dump(sorted_words, json_file, indent=4, ensure_ascii=True)
# all levels' dictionary names
levels = ['Beginner', 'Intermediate', 'Advanced', 'Proficient',
'GRE', 'IELTS', 'TOEFL', 'SAT', 'CET4', 'CET6', 'KaoYan',
'GMAT', 'Medical']
for level in levels:
process('relingo-' + level)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。