Created
October 10, 2016 08:49
-
-
Save TheoLeanse/41cc5828a03cdd26d53ae72a3a503bfc to your computer and use it in GitHub Desktop.
Sitemaps Healthcheck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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