Skip to content

pawanpaudel93/single-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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.

About

Save a url single page html and screenshot using puppeteer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •