-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherp_runner.js
90 lines (83 loc) · 2.7 KB
/
erp_runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const puppeteer = require("puppeteer");
const nodemailer = require("nodemailer");
const timehai = Date.now();
const nameuser = "xxxxxxxxx";
const pass = "@@@@@@@@@";
const screenshottimetable = async () => {
const browser = await puppeteer
.launch({
// headless: false,
defaultViewport: null,
args: ["--start-maximized"],
})
.catch((err) => {
console.log("Error biro : ", err);
});
const page = await browser.newPage();
await page.goto("https://erp.psitche.ac.in/");
const username = 'input[name="username"]';
await page.waitForSelector(username);
await page.type(username, nameuser);
const password = 'input[name="password"]';
await page.waitForSelector(password);
await page.type(password, pass);
const signinbutton = ".login-buttons";
await page.waitForSelector(signinbutton);
await page.click(signinbutton);
console.log("Before navigating to My TimeTable");
const timetable = "a[href='https://erp.psitche.ac.in/Student/MyTimeTable']";
await page.waitForSelector(timetable);
await page.click(timetable);
await page.waitForTimeout(6000);
const divSelector = ".table-responsive";
await page.waitForSelector(divSelector);
const divHandle = await page.$(divSelector);
const boundingBox = await divHandle.boundingBox();
await page.setDefaultNavigationTimeout(60000);
if (boundingBox) {
await page.screenshot({
path: "timetable" + timehai + ".jpeg",
clip: {
x: boundingBox.x,
y: boundingBox.y,
width: boundingBox.width,
height: boundingBox.height,
},
});
console.log("Screenshot taken successfully");
}
};
const sendmail = async function sendMail() {
const transporter = nodemailer.createTransport({
service: "gmail",
secure: true,
auth: {
user: "[email protected]",
pass: "nurmmdlwtkzevaks",
},
});
const mailOptions = {
from: "[email protected]",
subject: "😘😘💖😘😘😘",
text: "Hello, Looking Nice ...",
attachments: [
{
filename: "timetable" + timehai + ".jpeg",
path: "./timetable" + timehai + ".jpeg",
},
],
};
try {
const result = await transporter.sendMail(mailOptions);
console.log("Eamil sent successfully ☀️", result);
} catch (error) {
console.log("Email send failed with error:", error);
}
};
screenshottimetable().then(() => {
console.log("Sending Time table to all the provided mails now ");
sendmail();
});
// follow me guys at MY GITHUB
// https://github.com/saiyamdubey