Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remy/snap
Creates a static snapshot of a website. Sort of like wget's mirror mode, but with nice urls
https://github.com/remy/snap
Last synced: 16 days ago
JSON representation
Creates a static snapshot of a website. Sort of like wget's mirror mode, but with nice urls
- Host: GitHub
- URL: https://github.com/remy/snap
- Owner: remy
- Created: 2017-05-03T09:39:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T19:13:09.000Z (over 6 years ago)
- Last Synced: 2024-10-14T06:26:40.157Z (about 1 month ago)
- Language: JavaScript
- Size: 32.2 KB
- Stars: 99
- Watchers: 5
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Snap
Like `wget -r ` but specifically designed to support "pretty" URLs. With `wget`, a URL pointing to `/foo` would result in `/foo.html`, but this means the URL has now changed.
With `snap`, it will create the directory `/foo` and save the file to `/foo/index.html` so that the URL `/foo` still works.
## Installation
Via npm:
```
npm install @remy/snap
```## Usage
```
$ snap # saves to directory matching the domain
$ snap --output
$ snap -o # short hand
```## Example usage
This is how I'm using `snap` in an Express web site to generate a static copy of the site before deploying to Amazon S3.
The scripts section of my `package.json`:
```
{
"scripts": {
"start": "node .",
"prebuild": "NODE_ENV=production PORT=7331 node . & echo $! > .pid; sleep 1",
"build": "snap http://localhost:7331 -o www; kill $(cat .pid); rm .pid"
},
"devDependencies": {
"@remy/snap": "^1.0.1"
}
}
```## Notes and limitations
- If the output directory already exists, it will be removed first by `snap`
- Crawling is limited to the domain specified
- Speed and interval has been set to run as fast as possible, so this is ideally used with local domains
- There are no other arguments to `snap`, if further customisation is needed, please send a PR or look at using [simplecrawler](https://www.npmjs.com/simplecrawler)