-
Notifications
You must be signed in to change notification settings - Fork 19
/
snapshot.js
33 lines (30 loc) · 901 Bytes
/
snapshot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Simple page snapshots example.
* Copyright (c) 2013 - 2024, Alex Grant, LocalNerve, contributors
*
* Use sitemap index to drive input to snapshot individual pages.
*/
const htmlSnapshots = require('html-snapshots');
// where the snapshots go
const outputDir = require('path').join(__dirname, './tmp');
// If you want to crawl a huge map:
// 'https://www.usgs.gov/sitemap.xml',
// Do it:
htmlSnapshots.run({
input: 'sitemap-index',
source: 'http://bestplacestowork.org/sitemap_index.xml',
outputDir,
outputDirClean: true,
selector: 'body',
timeout: 60000
})
.then(completed => {
console.log('completed #', completed.length);
console.log('completed snapshots:');
console.log(require('util').inspect(completed));
})
.catch(err => {
console.error('completed #', err.completed.length);
console.error('not completed #', err.notCompleted.length)
console.error(err);
});