当前位置:网站首页>data:image/jpg;base64格式数据转化为图片
data:image/jpg;base64格式数据转化为图片
2022-08-04 06:20:00 【西门一刀】
在做爬虫爬取图片时,发现有的图片url是用“data:image/jpg;base64” 开头的,例如下图
此时获取url之后需要对url进行base64解密,解密之后的数据即可写入图片,详见下方代码
img_imf = img_imf.replace('data:image/jpg;base64,','')
#将data:image/jpg;base64格式的数据转化为图片
page_content = base64.b64decode(img_imf)
file_path = './code.jpg'
with open(file_path, 'wb') as f:
f.write(page_content)
边栏推荐
猜你喜欢
随机推荐
MySQL配置文件配置
两日总结六
MySQL内存淘汰策略
水平垂直居中的12种方法,任意插入节点的方法,事件的绑定的三种方法和解绑的方法,事件对象,盒子模型
【学习笔记】状压dp
Verilog“七宗罪”
Error occurred while trying to proxy request项目突然起不来了
窥探晶体世界的奥秘 —— 230种空间群晶体结构模型全在这里
秒杀系统设计
JVM工具之 JPS
在线问题反馈模块实战(十八):实现excel台账文件记录批量导入功能
C语言指针
Gramm Angle field GAF time-series data into the image and applied to the fault diagnosis
matlab封闭曲线拟合 (针对一些列离散点)
mysql基础(4)
SystemVerilog-条件(三元)运算符
10个程序员可以接私活的平台和一些建议,赚麻...
用手机也能轻松玩转MATLAB编程
【并发】概念
FCN - the originator of semantic segmentation (based on tf-Kersa reproduction code)









