今天就跟大家聊聊有關(guān)使用Node.js怎么批量下載圖片,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
成都創(chuàng)新互聯(lián)主要從事成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)樂昌,十載網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
首先要獲取到圖片鏈接:
const img = [ "/upload/otherpic54/7732.jpg", "/upload/otherpic54/7733.jpg", "/upload/otherpic54/7734.jpg", "/upload/otherpic54/7735.jpg", "/upload/otherpic54/7736.jpg", "/upload/otherpic54/7737.jpg", "/upload/otherpic54/7738.jpg", "/upload/otherpic54/7739.jpg", "/upload/otherpic54/7740.jpg", "/upload/otherpic54/7741.jpg", "/upload/otherpic54/7742.jpg", "/upload/otherpic54/7743.jpg", "/upload/otherpic54/7744.jpg", "/upload/otherpic54/7745.jpg", "/upload/otherpic54/7746.jpg", "/upload/otherpic54/7747.jpg", "/upload/otherpic54/7748.jpg", "/upload/otherpic54/7749.jpg", "/upload/otherpic54/7750.jpg", "/upload/otherpic54/7751.jpg", "/upload/otherpic54/7752.jpg", "/upload/otherpic54/7753.jpg", "/upload/otherpic54/7754.jpg", "/upload/otherpic54/7755.jpg", "/upload/otherpic54/7756.jpg", "/upload/otherpic54/7757.jpg", "/upload/otherpic54/7758.jpg", "/upload/otherpic54/7759.jpg", "/upload/otherpic54/7760.jpg", "/upload/otherpic54/7761.jpg", "/upload/otherpic54/7762.jpg", "/upload/otherpic54/7763.jpg", "/upload/otherpic54/7764.jpg", "/upload/otherpic54/7765.jpg", "/upload/otherpic54/7766.jpg", "/upload/otherpic54/7767.jpg", "/upload/otherpic54/7768.jpg", "/upload/otherpic54/7769.jpg", "/upload/otherpic54/7770.jpg", "/upload/otherpic54/7771.jpg", "/upload/otherpic54/7772.jpg", "/upload/otherpic54/7774.jpg" ];
批量下載圖片:
var fs = require('fs'); var request = require("request"); img.forEach(src => { var writeStream = fs.createWriteStream(src.split('/2019/08/')[1]); var readStream = request(src) readStream.pipe(writeStream); readStream.on('end', function() { console.log('文件下載成功'); }); readStream.on('error', function() { console.log(1); // console.log("錯誤信息:" + err) }) writeStream.on("finish", function() { console.log("文件寫入成功"); writeStream.end(); }); });
看完上述內(nèi)容,你們對使用Node.js怎么批量下載圖片有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
網(wǎng)站題目:使用Node.js怎么批量下載圖片
分享URL:http://m.rwnh.cn/article0/ggdcoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、微信小程序、品牌網(wǎng)站制作、軟件開發(fā)、App設(shè)計、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)