diff --git a/app/utils/powerSchedule.js b/app/utils/powerSchedule.js
new file mode 100644
index 0000000..554b5d9
--- /dev/null
+++ b/app/utils/powerSchedule.js
@@ -0,0 +1,47 @@
+const puppeteer = require("puppeteer");
+const zulip = require("zulip-js");
+
+(async () => {
+ // Launch a headless browser
+ const browser = await puppeteer.launch({
+ headless: true,
+ args: ["--no-sandbox"],
+ });
+ const config = {
+ username: "networktool-bot@zulip.ipsupply.com.au",
+ apiKey: "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM",
+ realm: "https://zulip.ipsupply.com.au",
+ };
+ const client = await zulip(config);
+ // Open a new page
+ const page = await browser.newPage();
+ await page.goto("https://ithongtin.com/lich-cup-dien/can-tho/ninh-kieu");
+ const data = await page.evaluate(() => {
+ const title = document.title;
+ const paragraphText = document.querySelector("table").textContent;
+ return {
+ title,
+ paragraphText,
+ };
+ });
+ await browser.close();
+ let params = {
+ type: "stream",
+ to: "Result test - auto.nswteam.net",
+ topic: "Lịch cúp điện",
+ content:
+ ":warning: :date: :warning:\n" +
+ data.paragraphText
+ .split(" ")
+ .filter((i) => i.includes("KDC 91B") || i.includes("KDC91B"))[0].replace(/ /g,"\n\n").replace(/KDC 91B/g,"**KDC 91B**") +
+ "\n-------",
+ };
+
+ if (
+ data.paragraphText
+ .split(" ")
+ .filter((i) => i.includes("KDC 91B") || i.includes("KDC91B")).length > 0
+ ) {
+ client.messages.send(params);
+ }
+})();
\ No newline at end of file
diff --git a/screenshot.js b/screenshot.js
index 37c1124..de8b849 100644
--- a/screenshot.js
+++ b/screenshot.js
@@ -1,32 +1,56 @@
-// const puppeteer = require("puppeteer");
+const puppeteer = require("puppeteer");
+const zulip = require("zulip-js");
+// const axios = require("axios");
-const axios = require("axios");
+(async () => {
+ // Launch a headless browser
+ const browser = await puppeteer.launch({
+ headless: true,
+ args: ["--no-sandbox"],
+ });
+ const config = {
+ username: "networktool-bot@zulip.ipsupply.com.au",
+ apiKey: "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM",
+ realm: "https://zulip.ipsupply.com.au",
+ };
+ const client = await zulip(config);
+ // Open a new page
+ const page = await browser.newPage();
+ await page.goto("https://ithongtin.com/lich-cup-dien/can-tho/ninh-kieu");
+ const data = await page.evaluate(() => {
+ const title = document.title;
+ const paragraphText = document.querySelector("table").textContent;
+ return {
+ title,
+ paragraphText,
+ };
+ });
+ await browser.close();
+ let params = {
+ type: "stream",
+ to: "Result test - auto.nswteam.net",
+ topic: "Lịch cúp điện",
+ content:
+ ":warning: :date: :warning:\n" +
+ data.paragraphText
+ .split(" ")
+ .filter((i) => i.includes("KDC 91B") || i.includes("KDC91B"))[0].replace(/ /g,"\n\n").replace(/KDC 91B/g,"**KDC 91B**") +
+ "\n-------",
+ };
-// (async () => {
-// // Launch a headless browser
-// const browser = await puppeteer.launch({
-// headless: true,
-// args: ["--no-sandbox"],
-// });
-
-// // Open a new page
-// const page = await browser.newPage();
-// await page.goto(
-// "https://logs.danielvu.com/screenShot/20230913-TEST01-Session.Port4-6-172.16.20.7.log"
-// );
-// const bodyHandle = await page.$("body");
-// const { height } = await bodyHandle.boundingBox();
-// await bodyHandle.dispose();
-// await page.setViewport({ width: 1920, height: 500 });
-// setTimeout(async () => {
-// await page.screenshot({ path: "screenshot.png" });
-// await browser.close();
-// }, 5000);
-// // } else {
-// // console.error(`Element with class name '${className}' not found.`);
-// // }
-// // Close the browser
-// })();
+ if (
+ data.paragraphText
+ .split(" ")
+ .filter((i) => i.includes("KDC 91B") || i.includes("KDC91B")).length > 0
+ ) {
+ client.messages.send(params);
+ }
+ // }, 5000);
+ // } else {
+ // console.error(`Element with class name '${className}' not found.`);
+ // }
+ // Close the browser
+})();
// const zulip = require("zulip-js");
@@ -163,7 +187,6 @@ const axios = require("axios");
// uploadFileToZulip(filePath);
-
// const puppeteer = require("puppeteer");
// (async () => {
@@ -180,8 +203,6 @@ const axios = require("axios");
// })();
// const zulip = require("zulip-js");
-
-
// (async () => {
// const config = {
// username: "networktool-bot@zulip.ipsupply.com.au",
@@ -198,41 +219,41 @@ const axios = require("axios");
// console.log(await client.messages.send(params))
// })()
-(async()=>{
- let listLog = []
- let from = 20230926
- let to = 20230926
- const response = await axios.get("http://192.168.5.7:8080/");
- const responseAUTO = await axios.get(
- "http://192.168.5.7:8080/AUTOlog/"
- );
+// (async()=>{
+// let listLog = []
+// let from = 20230926
+// let to = 20230926
+// const response = await axios.get("http://192.168.5.7:8080/");
+// const responseAUTO = await axios.get(
+// "http://192.168.5.7:8080/AUTOlog/"
+// );
- let data1 = response.data.split("\n")
- .filter((i) => i.search(" i.search(" i.search(" i.search(" {
- let temp = u
- .slice(u.search(""))
- .split(">")[1];
+// const arrayLine = data1.concat(data2)
- if (
- parseInt(temp?.split("-")[0]) >= from &&
- parseInt(temp?.split("-")[0]) <= to
- ) {
- listLog.push(
- (u.slice(u.search("")).split(">")[1].includes("AUTO")?"http://192.168.5.7:8080/AUTOlog/":"http://192.168.5.7:8080/") +
- u.slice(u.search("")).split(">")[1] +
- " "
- );
- }
-});
- console.log(listLog)
-})()
\ No newline at end of file
+// // const arrayLineAUTO = data
+// // .split("\n")
+// // .filter((i) => i.search(" {
+// let temp = u
+// .slice(u.search(""))
+// .split(">")[1];
+
+// if (
+// parseInt(temp?.split("-")[0]) >= from &&
+// parseInt(temp?.split("-")[0]) <= to
+// ) {
+// listLog.push(
+// (u.slice(u.search("")).split(">")[1].includes("AUTO")?"http://192.168.5.7:8080/AUTOlog/":"http://192.168.5.7:8080/") +
+// u.slice(u.search("")).split(">")[1] +
+// " "
+// );
+// }
+// });
+// console.log(listLog)
+// })()