40 lines
913 B
JavaScript
40 lines
913 B
JavaScript
/*
|
|
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)
|
|
.then(response => response.blob())
|
|
.then(blob =>
|
|
{
|
|
if (blob.size)
|
|
{
|
|
var pagename = page;
|
|
if (page < 10) pagename = "00" + pagename;
|
|
else if (page < 100) pagename = "0" + pagename;
|
|
|
|
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); |