Skip to content
Snippets Groups Projects
Commit 2db720eb authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Fix search by date of adoption

parent f45fc1f7
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,7 @@ async function downloadTreaties({ ...@@ -61,6 +61,7 @@ async function downloadTreaties({
const page = await browser.newPage({ ignoreHTTPSErrors: true }) const page = await browser.newPage({ ignoreHTTPSErrors: true })
iterPeriods: for (;;) { iterPeriods: for (;;) {
let sortNeeded = false
await page.goto( await page.goto(
"https://basedoc.diplomatie.gouv.fr/exl-php/recherche/mae_internet___traites", "https://basedoc.diplomatie.gouv.fr/exl-php/recherche/mae_internet___traites",
) )
...@@ -81,6 +82,7 @@ async function downloadTreaties({ ...@@ -81,6 +82,7 @@ async function downloadTreaties({
await frameLocator await frameLocator
.locator('css=input[name="WHERE_INFEGAL_MAE_DATE_ADOPTION"]') .locator('css=input[name="WHERE_INFEGAL_MAE_DATE_ADOPTION"]')
.fill(today) .fill(today)
sortNeeded = true
} else { } else {
await frameLocator await frameLocator
.locator( .locator(
...@@ -101,11 +103,17 @@ async function downloadTreaties({ ...@@ -101,11 +103,17 @@ async function downloadTreaties({
let previousTraiteNumberAndCount = "" let previousTraiteNumberAndCount = ""
for (;;) { for (;;) {
// const frame = getFrameByName(page.mainFrame(), "query") as Frame
// assert.notStrictEqual(frame, undefined)
// await frame.waitForURL(/.*/, { waitUntil: "load" })
const frameLocator = page.frameLocator('css=[name="query"]') const frameLocator = page.frameLocator('css=[name="query"]')
if (adoption && sortNeeded) {
// Sort by date of adoption.
await frameLocator
.locator(`css=select[name="ORDERBY"]`)
.selectOption({ value: "MAE_DATE_ADOPTION" })
sortNeeded = false
continue
}
let firstNavigationTd: Locator let firstNavigationTd: Locator
let traiteNumberAndCount: string let traiteNumberAndCount: string
while (true) { while (true) {
...@@ -205,7 +213,8 @@ async function downloadTreaties({ ...@@ -205,7 +213,8 @@ async function downloadTreaties({
) )
previousTraiteNumberAndCount = traiteNumberAndCount previousTraiteNumberAndCount = traiteNumberAndCount
const latestDay = pageTreaties.at(-1)!["Date de signature"] const latestDay =
pageTreaties.at(-1)![adoption ? "Date d'adoption" : "Date de signature"]
if (traiteNumber + pageTreatiesRows.length >= traiteCount) { if (traiteNumber + pageTreatiesRows.length >= traiteCount) {
if (latestDay === currentDay) { if (latestDay === currentDay) {
break iterPeriods break iterPeriods
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment