forked from seantomburke/sitemapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.es6.js
41 lines (34 loc) · 1014 Bytes
/
example.es6.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
34
35
36
37
38
39
40
41
import Sitemapper from 'sitemapper';
(async () => {
const sitemapper = new Sitemapper();
const Google = new Sitemapper({
url: 'https://www.google.com/work/sitemap.xml',
debug: false,
timeout: 15000, // 15 seconds
});
try {
const data = await Google.fetch();
console.log(data.sites);
} catch(error) {
console.log(error);
}
sitemapper.timeout = 5000;
try {
const { url, sites } = await sitemapper.fetch('https://wp.seantburke.com/sitemap.xml');
console.log(`url:${url}`, 'sites:', sites);
} catch(error) {
console.log(error)
}
try {
const { url, sites } = await sitemapper.fetch('http://www.cnn.com/sitemaps/sitemap-index.xml');
console.log(`url:${url}`, 'sites:', sites);
} catch(error) {
console.log(error)
}
try {
const { url, sites } = await sitemapper.fetch('http://www.stubhub.com/new-sitemap/us/sitemap-US-en-index.xml');
console.log(`url:${url}`, 'sites:', sites);
} catch(error) {
console.log(error)
}
})();