From 03d1a453a6f2d2b67574304b92316d003aed5c5c Mon Sep 17 00:00:00 2001 From: Lizard Date: Wed, 11 Dec 2024 17:19:41 +0600 Subject: [PATCH] fix error in orgs.js --- .github/workflows/orgs.js | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/orgs.js b/.github/workflows/orgs.js index c8b4652..f806046 100644 --- a/.github/workflows/orgs.js +++ b/.github/workflows/orgs.js @@ -6,26 +6,27 @@ const agent = new https.Agent({ }); const fs = require('fs'); -let body = await fetch(`https://minjust.gov.ru/ru/documents/7756/`, { +fetch(`https://minjust.gov.ru/ru/documents/7756/`, { agent: agent }) -body = await body.text() -let parsed = parse(body) -let output = [] - -for(var i of parsed.querySelector("tbody").querySelectorAll("tr")) { - let obj = { - id: i.querySelectorAll("td")[0].textContent, - fullName: i.querySelectorAll("td")[3].textContent, - decisionInMinjust: i.querySelectorAll("td")[1].textContent, - decisionInGenproc: i.querySelectorAll("td")[2].textContent, - decisionOutMinjust: i.querySelectorAll("td")[4].textContent, - decisionOutGenproc: i.querySelectorAll("td")[5].textContent, - dateIn: (i.querySelectorAll("td")[1].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm) != null ? i.querySelectorAll("td")[1].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm)[0] : ""), - dateOut: (i.querySelectorAll("td")[4].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm) != null ? i.querySelectorAll("td")[4].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm)[0] : "") +.then(res => res.text()) +.then(body => { + let parsed = parse(body) + let output = [] + for(var i of parsed.querySelector("tbody").querySelectorAll("tr")) { + let obj = { + id: i.querySelectorAll("td")[0].textContent, + fullName: i.querySelectorAll("td")[3].textContent, + decisionInMinjust: i.querySelectorAll("td")[1].textContent, + decisionInGenproc: i.querySelectorAll("td")[2].textContent, + decisionOutMinjust: i.querySelectorAll("td")[4].textContent, + decisionOutGenproc: i.querySelectorAll("td")[5].textContent, + dateIn: (i.querySelectorAll("td")[1].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm) != null ? i.querySelectorAll("td")[1].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm)[0] : ""), + dateOut: (i.querySelectorAll("td")[4].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm) != null ? i.querySelectorAll("td")[4].textContent.match(/\d{2}\.\d{2}\.\d{4}/gm)[0] : "") + } + output.push(obj) } - output.push(obj) -} - -fs.writeFileSync("./registry.json", JSON.stringify(output)) -console.log("Successful update") \ No newline at end of file + + fs.writeFileSync("./registry.json", JSON.stringify(output)) + console.log("Successful update") +}) \ No newline at end of file