1.0.7 • Published 7 months ago

@pawanpaudel93/single-file v1.0.7

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
7 months ago

@pawanpaudel93/single-file

Save a url single page html and screenshot using puppeteer.

Installation

Using npm,

npm install @pawanpaudel93/single-file

Using yarn,

yarn add @pawanpaudel93/single-file

And using pnpm,

yarn add @pawanpaudel93/single-file

Build

yarn
yarn build

Test

yarn test

Usage

import {saveSingleFile} from "../src/index"
import {promises} from "fs"
import { findChrome } from 'find-chrome-bin'
import { BrowserFetcher } from 'puppeteer-core'
import { join } from 'path'
import { homedir } from 'os'

const main = async () => {
  const outputDirectory = "./output"
  await promises.mkdir(outputDirectory)
  const chromePath = join(homedir(), '.cache', 'puppeteer')
  const { executablePath } = await findChrome({
    download: {
      puppeteer: { BrowserFetcher },
      path: chromePath,
      revision: '1095492',
    },
  })
  await saveSingleFile({
      url: 'https://arweave.org/',
      browserExecutablePath: executablePath,
      outputDirectory: outputDirectory,
      saveScreenshot: true
  })
  const files = await promises.readdir(outputDirectory)
  console.log(files)
}

main()

Acknowledgments

Modifications

  • Restructured the original code.
  • Added screenshot & metadata saving functionality.
  • Only used puppeteer as the backend and others are removed.
  • Converted the original CLI version to library to be used by others.

These modifications were made to create a package that can be used by others in their code easily.

License

  • This project is based on the Original Repository, which is licensed under the GNU Affero General Public License (AGPL). Any modifications made to the original code are also licensed under the AGPL.
1.0.7

7 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago