Skip to content

Commit

Permalink
Nom de fichiers DR
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour committed Nov 3, 2023
1 parent 9a9ca6e commit 95cfc5c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions puppeteer_scrapping/prodouane_stock.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const fs = require('fs');

content = await page.content()

fs.writeFileSync("documents/ds-"+process.env.CVI+".html",content);
fs.writeFileSync("documents/ds-"+process.env.PRODOUANE_ANNEE+'-'+process.env.CVI+".html",content);

if(content.includes("déclaration d'absence de stock")){
if(process.env.DEBUG){
Expand Down Expand Up @@ -225,9 +225,7 @@ const fs = require('fs');

await page.waitForTimeout(100);

pdf_newfilename = pdf_filename.replace('DeclarationStock', 'ds');
pdf_newfilename = pdf_newfilename.replace('_RecapitulatifInstallation', '');
pdf_newfilename = pdf_newfilename.replace('_', '-');
pdf_newfilename = 'ds-'+process.env.PRODOUANE_ANNEE+'-'+process.env.CVI+".pdf";
await fs.rename('documents/'+pdf_filename, 'documents/'+pdf_newfilename, (err) => {if (err) throw err;});

if(process.env.DEBUG){
Expand Down Expand Up @@ -256,10 +254,7 @@ const fs = require('fs');
return false;
});

xls_newfilename = xls_filename.replace('DeclarationStock', 'ds');
xls_newfilename = xls_newfilename.replace('_RecapitulatifInstallation', '');
xls_newfilename = xls_newfilename.replace('_', '-');

xls_newfilename = 'ds-'+process.env.PRODOUANE_ANNEE+'-'+process.env.CVI+".xls";
await page.waitForTimeout(5000); //attendre le téléchargement complet et non du fichier temporaire de chromium .crdownload

await fs.rename('documents/'+xls_filename, 'documents/'+xls_newfilename, (err) => {if (err) throw err;});
Expand Down

0 comments on commit 95cfc5c

Please sign in to comment.