Skip to content

Commit

Permalink
fix error in orgs.js
Browse files Browse the repository at this point in the history
  • Loading branch information
li0ard committed Dec 11, 2024
1 parent d14063d commit 03d1a45
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions .github/workflows/orgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

fs.writeFileSync("./registry.json", JSON.stringify(output))
console.log("Successful update")
})

0 comments on commit 03d1a45

Please sign in to comment.