Browse Source

first commit

master
n4n5 10 months ago
commit
0af5ab06a6
  1. 19
      index.js
  2. 14
      package.json

19
index.js

@ -0,0 +1,19 @@
const axios = require('axios');
const url = "https://tp.telecom-paris.fr";
const job = async () => {
const rep = await axios.get(url);
const dat = rep.data.split("<th>");
dat.shift()
const data = dat.map(el => {
return el.replace(/(.*)<\/th><.*?><span.*?>(.*?)<.*/gm, '$1 $2');
});
const final = data.filter((el)=>{
return el.endsWith("OK");
});
const randomInt = Math.floor(Math.random()*final.length);
process.stdout.write(final[randomInt].split(" ")[0]);
}
job();

14
package.json

@ -0,0 +1,14 @@
{
"name": "get-tp-name",
"version": "1.0.0",
"description": "Get an available tp machine name",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "n4n5",
"license": "MIT",
"dependencies": {
"axios": "^0.24.0"
}
}
Loading…
Cancel
Save