Created
October 30, 2019 11:18
-
-
Save gspncr/9333a66e7a1f697972306a903dff3574 to your computer and use it in GitHub Desktop.
New Relic Synthetics script to check for new food allergy alerts
This file contains 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
var parseString = require('xml2js').parseString; | |
var $http = require('request'); | |
// Get the New Relic status RSS feed | |
$http.get('https://www.food.gov.uk/rss-feed/alerts-allergy', function(err, response, body) { | |
parseString(body, function(err, result){ | |
// Parse the RSS, and get the latest incident | |
var latestIncident = result.rss.channel[0].item[0]; | |
// Push the incident details to Insights | |
$util.insights.set('newsTitle', latestIncident.title[0]); | |
$util.insights.set('Description', latestIncident.description[0]); | |
$util.insights.set('Date', latestIncident.pubDate[0]); | |
console.log(latestIncident.title[0]); | |
console.log(latestIncident.description[0]); | |
console.log(latestIncident.pubDate[0]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment