1 Star 0 Fork 229

koalamm638/python-learn

forked from mktime/python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
get_bookmarks.py 943 Bytes
一键复制 编辑 原始数据 按行查看 历史
mktime 提交于 2014-10-05 22:33 . test delicious convet script
#!/usr/bin/env python
#-*- coding=utf-8 -*-
from xml.dom import minidom
import sys
reload(sys)
sys.setdefaultencoding('utf8')
'''
date 2013-07-20 18:39:01
desc convert delicious xml file to boo markdown format
'''
def parse(xmlfile, outfile):
dom = minidom.parse(xmlfile)
root = dom.documentElement
l = root.getElementsByTagName("post")
f = open(outfile, "a")
for i in l:
link = i.getAttribute("href").decode('utf8')
desc = i.getAttribute("description").decode('utf8')
short = ""
if len(desc) < 7:
short = link[:25] + ">>"
else:
short = desc[:25] + ">>"
record = "[" + short + "](" + link + " \"" + desc + "\")\n\n"
f.write(record)
f.close()
if __name__ == '__main__':
if len(sys.argv) < 2:
print "usage: python get_bookmarks.py outfile"
sys.exit(127)
parse("delicious.xml", sys.argv[2].strip())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/koalamm638_admin/python-learn.git
git@gitee.com:koalamm638_admin/python-learn.git
koalamm638_admin
python-learn
python-learn
master

搜索帮助