presse/europressepdf.js

40 lines
913 B
JavaScript
Raw Normal View History

2024-06-19 12:28:15 +02:00
/*
Le monde: LM_P
Libé: LI_P
Courrier international: IL_P
Télérama: TA_P
*/
var paperid = "LM_P";
var date = "20240619";
var basename = paperid + "-" + date;
var baseurl = "https://nouveau.europresse.com/WebPages/Pdf/Document.aspx?DocName=pdf·" + date + "·" + paperid + "·";
function getpage(page)
{
fetch(baseurl + page)
2024-06-20 17:09:53 +02:00
.then(response => response.blob())
2024-06-19 12:28:15 +02:00
.then(blob =>
{
if (blob.size)
{
2024-06-20 10:18:54 +02:00
var pagename = page;
if (page < 10) pagename = "00" + pagename;
else if (page < 100) pagename = "0" + pagename;
2024-06-19 12:28:15 +02:00
var filename = basename + "-" + pagename + ".pdf";
var a = document.createElement('a');
a.href = window.URL.createObjectURL(blob);
a.download = filename;
a.click();
getpage(page + 1);
}
else
{
console.log("Merge command:");
console.log("pdfunite " + basename + "-*.pdf " + basename + ".pdf");
}
});
}
getpage(1);