用picgo 和 github 搭建一个免费的图床
1.新建一个github仓库
![](http://103.233.255.217/dulred/Pic/main/images202303110041754.png)
2.获取token
![](http://103.233.255.217/dulred/Pic/main/images202303110041019.png)
![](http://103.233.255.217/dulred/Pic/main/images202303110042485.png)
![](http://103.233.255.217/dulred/Pic/main/images202303110042576.png)
![](http://103.233.255.217/dulred/Pic/main/images202303110042966.png)
3.[下载安装picGo] (https://github.com/Molunerfinn/PicGo)
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303110042256.png)
4.配置picGo
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111215035.png)
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303110042080.png)
-
在github中自定义域名要写成这样,才可以直接导入其他博客平台 然后才显示图片
https://raw.githubusercontent.com/用户名/仓库名/分支
6.配置Typora
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111215366.png)
7.使用方法
在Typora中 右键图片直接上传,或者直接拉到picGo中上传就行
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111221531.png)
实战用法之直接导入到CSDN 展示
会可能出现图片不显示问题,外链转存失败
解决方案 将外链url 转成 <img src ="外链">的形式即可
解决工具:python脚本
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111221047.png)
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111221215.png)
import re
old_path = "./old_file.md" //本地路径的写法,这是准备转化的文件路径
new_path = "./new_file.md" //生成的文件
old_file = open(old_path, 'r', encoding='utf-8')
new_file = open(new_path, 'w', encoding='utf-8')
old_line = old_file.readline()
count = 0
while old_line:
if "![" in old_line:
url = re.findall('https://.*png|https://.*jpeg|https://.*jpg', old_line)
img = '<img src="' + url[0] + '"/>'
new_line = re.sub('!\[.*\)', img, old_line)
new_file.write(new_line)
print(old_line + ' ===> ' + new_line)
count += 1
else:
new_file.write(old_line)
old_line = old_file.readline()
old_file.close()
new_file.close()
![](https://raw.githubusercontent.com/dulred/Pic/main/images202303111244113.png)