Skip to content

Commit

Permalink
Possibility to get the id off all classes
Browse files Browse the repository at this point in the history
  • Loading branch information
TanguyLichau committed Jan 4, 2023
1 parent 51d39e0 commit 4177c66
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { cp } = require("fs");
const puppeteer = require("puppeteer");
require("dotenv").config();

Expand Down Expand Up @@ -28,12 +29,19 @@ async function validerAppel(uid, alvstu, simplesaml, samlauth) {
uid +
";",
},
body: new URLSearchParams({
act: "set_present",
seance_pk: "27747252",
}),
}
);
}

async function yo() {
const browser = await puppeteer.launch({ headless: false });
const browser = await puppeteer.launch({
headless: false,
defaultViewport: false,
});
const page = await browser.newPage();

await page.goto("https://www.leonard-de-vinci.net/");
Expand All @@ -60,8 +68,22 @@ async function yo() {

await page.goto("https://www.leonard-de-vinci.net/student/presences/");

const f = await page.$("#body_presences");
console.log(f);
const dob = await page.$$("#body_presences");

// Select all the links on the page
const links = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll("a"));
return anchors.map((a) => a.href);
});

// Filter the links to get the ones that match the regular expression
const regex = /\/student\/presences\/(\d+)/;
const matchingLinks = links.filter((link) => link.match(regex));

// Extract the digits from the matching links
const digits = matchingLinks.map((link) => link.match(regex)[1]);

console.log(digits);
}

yo();

0 comments on commit 4177c66

Please sign in to comment.