const https = require("https");
const fs = require("fs");
const url = "https://finans.truncgil.com/today.json";
const dosyaAdi = "dosya.json";
setInterval(() => {
https
.get(url, (response) => {
let veri = "";
response.on("data", (parca) => {
veri += parca;
});
response.on("end", () => {
fs.writeFile(dosyaAdi, veri, (hata) => {
if (hata) {
console.error("Dosyaya yazılırken bir hata oluştu:", hata);
} else {
console.log("Veriler başarıyla dosyaya kaydedildi.");
}
});
});
})
.on("error", (hata) => {
console.error("Veri alınırken bir hata oluştu:", hata);
});
}, 1000 * 60 * 5); // 5 dakika