首页 > 解决方案 > 如何在javascript中使用puppeteer获取默认文件目录

问题描述

我仍然需要用 apify(puppeteer) 查找下载文件。
我怎样才能得到它的路径。我使用 javascript。

非常感谢。致以最诚挚的问候

我使用下面的代码

function getCurrentFilenames() {
const path = require('path');
const downloadPath1 = path.resolve('/home/myuser/Downloads');//path.resolve(__dirname, './downloads');
  
const fs = require('fs');
  console.log("Current filenames:");
   fs.readdirSync(downloadPath1).forEach(file => {
    console.log(file);
  });
}

标签: filedownloadpathpuppeteer

解决方案


推荐阅读