const request = require('request') const readline = require('readline'); var path = require('path'); const fs = require('fs') const r1 = readline.createInterface({ input: fs.createReadStream("imgList.txt") }); r1.on('line', function(line){ var url = line reg = /http://[.w]+/([.w]+)?.*/ let writeStream=request(url).pipe(fs.createWriteStream('./img/'+reg.exec(url)[1])) writeStream.on('end', function () { console.log('结束了====='); }) ; })