WishMeLz

生活其实很有趣

下载文件

function downloadFile(u) {
    http.get(u, (res) => {
        var data = "";
        res.setEncoding('binary');
        res.on('data', function (chunk) {
            data += chunk
        })
        res.on('end', () => {
            let filename = Date.now();
            fs.writeFileSync(`./ppx/${filename}.mp4`, data, 'binary')
            console.log(filename + 'end');
        })
    })
}