Integrate SingleFIle into NodeJS
Hello, I'm currently working on an app and wanted to know how can I run SingleFile from NodeJS.
Cheers, Daniel
Hi Daniel,
I'm glad to hear that you would like to integrate SingleFile in your app :). There are 2 main ways to run SingleFile from NodeJS. You can use JSDOM, see https://github.com/gildas-lormeau/single-file-cli/blob/master/back-ends/jsdom.js, and run SingleFile directly in Node. In this case, the JavaScript won't be executed and the resulting page might be altered. For example, lazy-loaded images might be missing. Otherwise, you can run SingleFile in a headless browser via puppeteer for example, see other files here: https://github.com/gildas-lormeau/single-file-cli/tree/master/back-ends. I do not recommend to use Selenium though. With puppeteer, you should get more or less the same result as the extension. An overview of the integration of SingleFile is explained here: https://github.com/gildas-lormeau/SingleFile/wiki/How-to-integrate-SingleFile-library-code-in-%22custom%22-environments%3F
Please let me know if you need more details.
I'm closing and moving this issue in the "Discussions" tab.