博客园文章导出

备份

博客园备份导出“.db”文件。

python脚本生成.md文件

数据库表中的字段对应

  • title - 文章标题
  • body - 文章正文内容
import sqlite3

con = sqlite3.connect(".db")

cur = con.cursor()

sql = "select title, body from blog_content"
cur.execute(sql)
titleAndBody = cur.fetchall()

for i in titleAndBody:
    filePath = "./"
    fileName = i[0] + ".md"
    f = open(filePath + fileName, "w", encoding='utf-8')
    f.write(i[1])
    f.close()

批量下载图片

用的linux环境执行,需要先用dos2unix将文件都优化一下,否则以下命令执行会导致每行末尾加上"%0D"

for i in  `awk -F '(' '/\!\[image\]/{print $2}' * |sed "s/)//"`;do wget $i;done
posted @ 2024-07-26 10:13  ヾ(o◕∀◕)ノヾ  阅读(54)  评论(0)    收藏  举报