我想从https://www.sec.gov/Archives/edgar/full-index/2018/QTR1/company.zip
下载文件,并且想指定要保存在计算机上的路径,但是我不想使用任何浏览器中间件。有人可以指导我如何用JavaScript编写脚本以从url下载文件并将其保存在我的PC上
答案 0 :(得分:2)
与chintuyadavsara said一样,用您的网址填充this answer可以达到目的:
const https = require('https');
const fs = require('fs');
function go (src, dest) {
const file = fs.createWriteStream(dest);
const request = https.get(src, function(response) {
response.pipe(file);
});
}
go('https://www.sec.gov/Archives/edgar/full-index/2018/QTR1/company.zip', './company.zip');