代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。