Skip to content

Instantly share code, notes, and snippets.

@TheoLeanse
Created October 10, 2016 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheoLeanse/41cc5828a03cdd26d53ae72a3a503bfc to your computer and use it in GitHub Desktop.
Save TheoLeanse/41cc5828a03cdd26d53ae72a3a503bfc to your computer and use it in GitHub Desktop.
Sitemaps Healthcheck
const denodeify = require('denodeify');
const xml2js = denodeify(require('xml2js').parseString);
require('isomorphic-fetch');
const twoDaysAgo = new Date();
twoDaysAgo.setUTCDate(twoDaysAgo.getUTCDate() - 2);
fetch('https://www.ft.com/sitemaps/news.xml', {
headers: {
'Cookie': 'FT_SITE=DUBNEXT'
}
})
.then(results => results.text())
.then(results => xml2js(results))
.then(results => results.urlset.url.filter(result => result['news:news'][0]['news:publication_date'][0] <= twoDaysAgo.toISOString()))
.then(results => results.forEach(result => console.log(result['news:news'][0]['news:publication_date'][0])))
.catch(err => console.log('err=', err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment