-
Notifications
You must be signed in to change notification settings - Fork 1
/
manually-browse-sitemap.js
47 lines (38 loc) · 1.1 KB
/
manually-browse-sitemap.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
42
43
44
45
46
47
// Google Search Console reports 500 errors for pages.
// Hence, manually navigate to each and make them work.
// After doing this, pages should be indexable.
'use strict'
const fs = require('fs')
const sitemapArray = require('sitemap-to-array')
const URL = 'https://www.ineednature.co.nz/sitemap-0.xml';
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: true,
});
const options = {
returnOnComplete: true
}
sitemapArray(URL, options, async (err, list) => {
if (err) {
console.error(err)
}
else {
console.log('list: ', list);
var count = 0;
for (var o of list) {
count++;
await goToURL(browser, o.loc, count);
}
await browser.close();
}
})
})();
const goToURL = async (browser, url, count) => {
console.log(`${count}/${listLength} - going to url: ${url}`);
const page = await browser.newPage();
await page.goto(url, {
waitUntil: 'networkidle2',
});
await page.close();
}