当前需求:python爬取图片后到后端进行存储到MongoDB
第一次做全栈图片存储的项目,记录一下
@Data
@Document
@Accessors(chain = true)
public class PicUpload implements Serializable {
@Id
private String id;
private Binary content;
private String contentType;
}
这个是MongoDB存储的对象格式
response = requests.get("https://img2.baidu.com/it/u=1685092271,2574681286&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=797").content
requests.post(url="http://localhost:8080/test",data=response)
python的脚本只做个示例,第一行是获取图片的二进制数据,第二行是把二进制数据发到后端接口去,具体处理方法看后端
private