hackmd 用的圖床 imgur 要清掉舊圖了
怕 hackmd 文件裡面的圖全都被清光 所以來備份一下
- 設定 > 筆記設定 > 備份 > 下載所有筆記
- 解壓縮
- 把 image.py 搬進去同個資料夾
- 執行 image.py
wget -i url.txt
來下載所有圖片
import glob | |
import re | |
f = [] | |
for fn in glob.glob("*.md"): | |
with open(fn, encoding="utf-8") as md: | |
content = md.read() | |
urls = re.findall("(https\://i\.imgur\.com/\w+\.(?:png|jpg|gif))", content) | |
if urls: | |
f += urls | |
with open("url.txt", "w") as wf: | |
wf.writelines(l + "\n" for l in f) |