-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.js
54 lines (41 loc) · 1.98 KB
/
console.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
import puppeteer from 'puppeteer';
import fs from 'fs';
// Set the DEBUG environment variable to an empty string
process.env.DEBUG = '';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
console.log("Browsing...");
// Navigate to the page
await page.goto('https://web.javainstitute.org/web-portal/login/student.jsp');
console.log("Loggin in...");
console.log("");
// Enter login credentials
await page.type('input[name="username"]', 'Enter here your username(or nic you normally use to login)');
await page.type('input[name="password"]', 'Enter here your password');
await page.click('button[type="submit"]');
await page.waitForNavigation();
// Use page.$eval to directly get the inner text of the element with the specified class
const username = await page.$eval('.username.username-hide-on-mobile', element => element.innerText);
console.log("Logged in as " + username);
console.log("");
// Extract information from columns with background color "#d3f6ef"
const columns = await page.$$('.mt-element-ribbon.tt-height[style*="background-color:#d3f6ef;"]');
for (const column of columns) {
const date = await column.$eval('.ribbon-color-success', element => element.textContent.trim());
const subject = await column.$eval('.bg-grey-cararra', element => element.textContent.trim());
const time = await column.$eval('.col-md-12.bg-grey.bold', element => element.textContent.trim());
const joinLink = await column.$eval('a[target="_blank"]', element => element.getAttribute('href'));
console.log('Date:', date);
console.log('Subject:', subject);
console.log('Time:', time);
console.log('Join Link:', joinLink);
console.log('---');
}
// Close the browser
await browser.close();
// Pause and wait for user input before exiting
console.log("");
console.log('Press any key to exit...');
process.stdin.once('data', process.exit);
})();