Add JSON files containing Légifrance URLs of échéanciers. Improve détection of échéanciers
This commit is contained in:
parent
1fb1d20bee
commit
ad7df427e8
1 changed files with 23 additions and 6 deletions
|
@ -67,7 +67,10 @@ async function downloadDoleHtml(
|
||||||
break iterXmlFiles
|
break iterXmlFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dossierLegislatif.CONTENU.ECHEANCIER !== undefined) {
|
if (
|
||||||
|
dossierLegislatif.CONTENU.ECHEANCIER !== undefined ||
|
||||||
|
dossierLegislatif.CONTENU.CONTENU_DOSSIER_5 !== undefined
|
||||||
|
) {
|
||||||
if (!silent && verbose) {
|
if (!silent && verbose) {
|
||||||
console.log(
|
console.log(
|
||||||
`Retrieving échéancier of dossier législatif ${dossierLegislatif.META.META_COMMUN.ID}…`,
|
`Retrieving échéancier of dossier législatif ${dossierLegislatif.META.META_COMMUN.ID}…`,
|
||||||
|
@ -80,7 +83,9 @@ async function downloadDoleHtml(
|
||||||
).window
|
).window
|
||||||
const echeancierA = [
|
const echeancierA = [
|
||||||
...dossierLegislatifDocument.querySelectorAll("a.marker").values(),
|
...dossierLegislatifDocument.querySelectorAll("a.marker").values(),
|
||||||
].filter((aElement) => aElement.innerHTML.trim() === "Echeancier")[0]
|
].filter((aElement) =>
|
||||||
|
["Echeancier", "Echéancier"].includes(aElement.innerHTML.trim()),
|
||||||
|
)[0]
|
||||||
if (echeancierA === undefined) {
|
if (echeancierA === undefined) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -98,9 +103,11 @@ async function downloadDoleHtml(
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const echeancierHtml = await fetchHtmlPage(
|
const echeancierUrl = new URL(
|
||||||
new URL(echeancierRelativeUrl, dossierLegislatifUrl).toString(),
|
echeancierRelativeUrl,
|
||||||
)
|
dossierLegislatifUrl,
|
||||||
|
).toString()
|
||||||
|
const echeancierHtml = await fetchHtmlPage(echeancierUrl)
|
||||||
const { document: echeancierDocument } = new JSDOM(echeancierHtml)
|
const { document: echeancierDocument } = new JSDOM(echeancierHtml)
|
||||||
.window
|
.window
|
||||||
const echeancierTable = echeancierDocument.querySelector(
|
const echeancierTable = echeancierDocument.querySelector(
|
||||||
|
@ -115,6 +122,16 @@ async function downloadDoleHtml(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fs.writeJson(
|
||||||
|
path.join(
|
||||||
|
echeanciersHtmlDir,
|
||||||
|
`${dossierLegislatif.META.META_COMMUN.ID}_echeancier.json`,
|
||||||
|
),
|
||||||
|
{
|
||||||
|
legifranceUrl: echeancierUrl,
|
||||||
|
},
|
||||||
|
{ encoding: "utf-8", spaces: 2 },
|
||||||
|
)
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
path.join(
|
path.join(
|
||||||
echeanciersHtmlDir,
|
echeanciersHtmlDir,
|
||||||
|
@ -137,7 +154,7 @@ async function downloadDoleHtml(
|
||||||
await $`git add .`
|
await $`git add .`
|
||||||
if ((await $`git diff --quiet --staged`.exitCode) !== 0) {
|
if ((await $`git diff --quiet --staged`.exitCode) !== 0) {
|
||||||
changed = true
|
changed = true
|
||||||
const message = `Récupération des tables des échéanciers - ${new Date().toISOString()}`
|
const message = `Récupération des infos en HTML des échéanciers - ${new Date().toISOString()}`
|
||||||
await $`git commit -m ${message} --quiet`
|
await $`git commit -m ${message} --quiet`
|
||||||
if (push) {
|
if (push) {
|
||||||
await $`git push`
|
await $`git push`
|
||||||
|
|
Loading…
Reference in a new issue