1 Star 0 Fork 0

sidgwick/words

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
example.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
Zhigang Song 提交于 2018-06-13 16:52 . initial commit
import sys
import requests
from mongo import MongoService
class ShanBeiWord(object):
def __init__(self, result, log):
self.mongo = MongoService()
self.result = open(result, 'w')
self.log = open(log, 'w')
def word_detail(self, word):
word_detail = mongo.find_word(word)
get_data = {'type': 'yes', 'vocabulary_id': word_detail['content_id']}
res = requests.get("https://api.shanbay.com/bdc/example/",
params=get_data)
self.result.write(f"{word}: {res.text}\n")
log = ""
res_json = res.json()
if res_json['status_code'] == 0:
self.mongo.save_example(res_json['data'])
else:
log = f"[ERROR] word {word} not save: {res.text}\n"
log += f"[LOG] {word}: {res.status_code} - {res_json['msg']}"
self.log.write(log + "\n")
print(log)
mongo = MongoService()
word_list = mongo.word_list()
shanbei = ShanBeiWord(sys.argv[1], sys.argv[2])
for word in word_list:
if not word:
continue
shanbei.word_detail(word)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sidgwick/words.git
git@gitee.com:sidgwick/words.git
sidgwick
words
words
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385