Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pawanpaudel93/single-file
Save a url single page html and screenshot using puppeteer.
https://github.com/pawanpaudel93/single-file
Last synced: about 2 months ago
JSON representation
Save a url single page html and screenshot using puppeteer.
- Host: GitHub
- URL: https://github.com/pawanpaudel93/single-file
- Owner: pawanpaudel93
- License: agpl-3.0
- Created: 2023-06-23T06:36:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-04T17:50:19.000Z (over 1 year ago)
- Last Synced: 2023-10-05T06:03:51.486Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 820 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# @pawanpaudel93/single-file
Save a url single page html and screenshot using [puppeteer](https://github.com/puppeteer/puppeteer).
## Installation
Using npm,
```sh
npm install @pawanpaudel93/single-file
```Using yarn,
```sh
yarn add @pawanpaudel93/single-file
```And using pnpm,
```sh
yarn add @pawanpaudel93/single-file```
## Build
```sh
yarn
yarn build
```## Test
```sh
yarn test
```## Usage
```ts
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](https://github.com/gildas-lormeau/single-file-cli) by [Gildas Lormeau](https://github.com/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](https://github.com/gildas-lormeau/single-file-cli), which is licensed under the GNU Affero General Public License (AGPL). Any modifications made to the original code are also licensed under the AGPL.