The picture of blob downloaded through responseType = blob uses wirteFileSync to write to the local picture and opens incorrectly.

    async function downImgForSrc(src){
        if(!src)return
        let params = {
            url: src,
            method: "get",
            responseType: "blob"
        }
        try{
            let res = await axios(params)
            let blob = res.data
            fs.writeFileSync("img", blob)
        }catch(e){
            console.log("down img error", e)
        }
    }

No error was reported, but the picture I opened was wrong. Is there something wrong with it? Please take a look at

Dec.23,2021

 request('https://img.codeshelper.com/upload/img/2021/12/23/juvwwvgssp02030.png').pipe(fs.createWriteStream('google.png'))

Pictures have been downloaded in this way

Menu