You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
822 B
24 lines
822 B
const fs = require('fs'); |
|
|
|
// const fetch = require('node-fetch'); // Install this via npm |
|
|
|
|
|
async function downloadFile(url, path) { |
|
try { |
|
const response = await fetch(url); |
|
if (!response.ok){ |
|
throw new Error(`HTTP error! Status: ${response.status}`); |
|
} |
|
const arrayBuffer = await response.arrayBuffer(); |
|
const buffer = Buffer.from(arrayBuffer); |
|
fs.writeFileSync(path, buffer); |
|
console.log('File downloaded and saved successfully.'); |
|
} catch (error) { |
|
console.error('Error downloading the file:', error); |
|
} |
|
} |
|
|
|
const downloadUrl = 'https://app.yunnan.chinatax.gov.cn/GVv7ud1ebech/MO5zzCMcub4d.b4c45da.js'; // Replace with your file URL |
|
const filePath = './downloadedFile.js'; // Desired file path |
|
|
|
downloadFile(downloadUrl, filePath);
|
|
|