ANAC/gov.br now serves an F5 Bot Defense JS challenge instead of the real page
get_flight_dates_available() (and therefore latest_flights_date(), which
just wraps it) no longer works because the ANAC page it scrapes is now
sitting behind an F5 BIG-IP Bot Defense (Shape) JavaScript challenge.
Repro:
url <- 'https://www.gov.br/anac/pt-br/assuntos/regulados/empresas-aereas/Instrucoes-para-a-elaboracao-e-apresentacao-das-demonstracoes-contabeis/envio-de-informacoes'
h <- rvest::read_html(url)
cat(substr(rvest::html_text(h), 1, 300))
Instead of the real page, this returns an unexecuted bot-defense challenge
script (variables/cookies named bobcmn, TSPD_101, TSPD_101_DID — the
standard F5 Bot Defense/ASM signature). Since rvest::read_html() runs on
libcurl and never executes JavaScript, it can never pass this challenge.
Effect on the function: html_elements(h, "a") finds no /basica links
(the challenge page has none), so basica_urls ends up empty and the
function silently returns numeric(0) instead of erroring — no dates,
no explanation.
Reproduced independently from two unrelated networks/IPs, so this isn't an
IP-reputation block — it looks like a blanket JS-execution gate that will
reject any plain HTTP client (rvest, httr, curl, requests, etc.) regardless
of origin.
Possible directions:
- Render the page with a headless browser (e.g.
chromote) to pass the JS
challenge before parsing — though Bot Defense is designed to also detect
and block headless Chrome, so this may not be durable.
- Check whether the actual
basica CSV files are hosted on a different,
non-WAF-protected subdomain (the index page's links, not the files
themselves, appear to be the only thing scraped here) — if so,
date-discovery could avoid the www.gov.br page entirely.
- Check for an official ANAC/dados.gov.br open-data API that lists the same
files without going through the portal's bot wall.
ANAC/gov.br now serves an F5 Bot Defense JS challenge instead of the real page
get_flight_dates_available()(and thereforelatest_flights_date(), whichjust wraps it) no longer works because the ANAC page it scrapes is now
sitting behind an F5 BIG-IP Bot Defense (Shape) JavaScript challenge.
Repro:
Instead of the real page, this returns an unexecuted bot-defense challenge
script (variables/cookies named
bobcmn,TSPD_101,TSPD_101_DID— thestandard F5 Bot Defense/ASM signature). Since
rvest::read_html()runs onlibcurl and never executes JavaScript, it can never pass this challenge.
Effect on the function:
html_elements(h, "a")finds no/basicalinks(the challenge page has none), so
basica_urlsends up empty and thefunction silently returns
numeric(0)instead of erroring — no dates,no explanation.
Reproduced independently from two unrelated networks/IPs, so this isn't an
IP-reputation block — it looks like a blanket JS-execution gate that will
reject any plain HTTP client (rvest, httr, curl, requests, etc.) regardless
of origin.
Possible directions:
chromote) to pass the JSchallenge before parsing — though Bot Defense is designed to also detect
and block headless Chrome, so this may not be durable.
basicaCSV files are hosted on a different,non-WAF-protected subdomain (the index page's links, not the files
themselves, appear to be the only thing scraped here) — if so,
date-discovery could avoid the
www.gov.brpage entirely.files without going through the portal's bot wall.