SingleFile icon indicating copy to clipboard operation
SingleFile copied to clipboard

Integrate SingleFIle into NodeJS

Open daniel31x13 opened this issue 3 years ago • 1 comments

Hello, I'm currently working on an app and wanted to know how can I run SingleFile from NodeJS.

Cheers, Daniel

daniel31x13 avatar Jul 03 '22 22:07 daniel31x13

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.

gildas-lormeau avatar Jul 06 '22 22:07 gildas-lormeau

I'm closing and moving this issue in the "Discussions" tab.

gildas-lormeau avatar Nov 05 '22 00:11 gildas-lormeau