async function compareURL(page, url) {
const currentURL = await page.evaluate(() => document.location.href);
if (currentURL === url) {
if (!fs.existsSync("LinkYok.txt")) {
fs.writeFileSync(
"LinkYok.txt",
`Sayfa URL'si aynı: ${currentURL} ve ${url} \r\n`
);
} else {
fs.open("LinkYok.txt", "a", 666, function (e, id) {
fs.write(
id,
`Sayfa URL'si aynı: ${currentURL} ve ${url} \r\n`,
null,
"utf8",
function () {
fs.close(id);
}
);
});
}
} else {
if (!fs.existsSync("LinkVar.txt")) {
fs.writeFileSync(
"LinkVar.txt",
`Sayfa farklı URL'de. Güncel URL: ${currentURL} \r\n`
);
} else {
fs.open("LinkVar.txt", "a", 666, function (e, id) {
fs.write(
id,
`Sayfa farklı URL'de. Güncel URL: ${currentURL} \r\n`,
null,
"utf8",
function () {
fs.close(id);
}
);
});
}
}
}