Skip to content

Instantly share code, notes, and snippets.

@supphawit
Last active March 10, 2022 03:34
Show Gist options
  • Save supphawit/48e3751022f3d3331c95aac57e2854cf to your computer and use it in GitHub Desktop.
Save supphawit/48e3751022f3d3331c95aac57e2854cf to your computer and use it in GitHub Desktop.
const https = require("https");
let argv = process.argv[2];
let options = {
hostname: "codequiz.azurewebsites.net",
path: "/",
method: "GET",
headers: { Cookie: "hasCookie=true" },
};
let answer;
let req = https.request(options, function (res) {
let body = "";
res.on("data", function (chunk) {
body = body + chunk;
});
res.on("end", function () {
let table = "<table>" + body.split(/<table>|<\/table>/)[1] + "</table>";
let filter = table.split(/<td>|<\/td>/).map((e) => e.trim());
let find = filter.indexOf(argv);
let ans = filter.splice(find, 8).filter((e) => e);
answer = ans[1];
console.log(answer);
});
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment