Zakładam, że nie masz archaicznej przeglądarki, wklej to do konsoli JS na tamtej stronie i wciśnij enter (w chrome konsola jest pod CTRL+Shift+j
):
{
const save = (data) => {
const filename = `links.txt`
const blob = new Blob([data], { type: "text/plain" })
let e = document.createEvent("MouseEvents")
let a = document.createElement("a")
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ["text/json", a.download, a.href].join(":")
e.initMouseEvent(
"click",
true,
false,
window,
0,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null,
)
a.dispatchEvent(e)
}
const go = (page, amount) =>
fetch(
`https://www.inegi.org.mx/app/api/productos/interna_v1/slcComponente/obtenCartasBuscador?entidad=&municipio=&localidad=&tema=0150002000000000&escala=&formato=&edicion=&clave=&buscador=&tipoB=2&orden=4&ordenDesc=true&pagina=${page}&tamano=${amount}&_=1564079057160`,
{
credentials: "include",
headers: {
accept: "application/json, text/javascript, */*; q=0.01",
"accept-language": "pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7",
"x-requested-with": "XMLHttpRequest",
},
referrer:
"https://www.inegi.org.mx/temas/relieve/continental/default.html",
referrerPolicy: "no-referrer-when-downgrade",
body: null,
method: "GET",
mode: "cors",
},
)
.then((r) => r.json())
.then((result) => {
return result.mapas.map((item) => {
const urls = []
const links = $(item.formatos).find("a").get()
links.forEach(link => urls.push(link.href))
return urls
})
})
const main = async () => {
const allLinks = []
for (let i = 0; i < 66; i++) {
const links = await go(i, 1000)
console.log(`Fetched ${1000 * (i + 1)} items`)
links.forEach((link) => allLinks.push(link))
}
save(allLinks.join("\n"))
}
main()
}