1 Star 0 Fork 3

方阙/dict

forked from 潘少军/dict 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
export.py 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
kajweb 提交于 2019-02-22 18:41 . fx
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
# SETP3 : 导出md的表格
import requests
import json
import urllib
import os
export = "|序号|图片|标题|单词数量|文件大小|背诵人数|下载地址|id|标签|\n";
export = export + "|---|---|---|---|---|---|---|---|---|\n";
def getTag( tag ):
result = [];
for i in tag:
result.append(i["tagName"]);
return "、".join(result);
with open("./bookLists.txt",'r',encoding='UTF-8') as load_f:
load_dict = json.load(load_f)
bookLists = load_dict['data']['normalBooksInfo']
bookLen = len(bookLists);
nowIndex = 0;
for i in bookLists:
nowIndex = nowIndex +1;
id = i['id']
picUrl = i['cover']
title = i['title']
wordNum = i['wordNum']
fizeSize = i['size']
reciteUserNum = i['reciteUserNum']
fileUrl = i['offlinedata'];
# tag = "";
tag = getTag(i['tags']);
filename = os.path.basename(fileUrl)
basefile = "book/";
picMD = "![{}]({})".format(title,picUrl);
downloadUrl = "[{}]({}{}) [{}]({})".format( "本地地址",basefile,filename, "原始地址",fileUrl,);
item = "|{}|{}|{}|{}|{}|{}|{}|{}|{}|\n".format(nowIndex,picMD,title,wordNum,fizeSize,reciteUserNum,downloadUrl,id,tag)
export = export + item;
print( export )
with open("./export.txt",'w',encoding='UTF-8') as f:
f.write( export );
f.close
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fangque/dict.git
git@gitee.com:fangque/dict.git
fangque
dict
dict
master

搜索帮助