async function searchPage(page, pattern = [], trueFilePath, falseFilePath) {
const content = await page.content();
let result = false;
for (let i = 0; i < pattern.length; i++) {
if (content.replace(/\s/g, "").includes(pattern[i])) {
result = true;
break;
}
}
const filePath = result ? trueFilePath : falseFilePath;
const text = result ? "Bulundu \r\n" : "Bulunamadı \r\n";
if (!fs.existsSync(filePath)) {
fs.writeFileSync(filePath, text);
} else {
fs.open(filePath, "a", 666, function (e, id) {
fs.write(id, text, null, "utf8", function () {
fs.close(id);
});
});
}
}