38 lines
881 B
JavaScript
38 lines
881 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)
|
||
|
{
|
||
|
console.log("Downloading page " + page);
|
||
|
var pagename = page < 10 ? "0" + page : page;
|
||
|
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);
|