1.0.7 • Published 2 years ago
@pawanpaudel93/single-file v1.0.7
@pawanpaudel93/single-file
Save a url single page html and screenshot using puppeteer.
Installation
Using npm,
npm install @pawanpaudel93/single-fileUsing yarn,
yarn add @pawanpaudel93/single-fileAnd using pnpm,
yarn add @pawanpaudel93/single-fileBuild
yarn
yarn buildTest
yarn testUsage
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
- This project is based on the Original Repository by Gildas Lormeau.
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.