I have an array of news updates coming from this website here. What I am looking to do is console.log the latest news articles as they are published, or very close to when they are posted. With my code, I can send a request to obtain the articles, but I want to know when the array changes with a new entry.
const axios = require('axios')
const cheerio = require('cheerio')
const express = require('express')
const PORT = 3000
const URL = 'https://www.newworld.com/en-us/news'
const splitURL = URL.slice(0, 24)
const app = express()
setInterval(() => {
axios(URL)
.then(response => {
const html = response.data
const $ = cheerio.load(html)
const articles = []
$('.ags-SlotModule', html).each(function(){
const link = splitURL + $(this).find('a').attr('href')
articles.push({
link
})
})
console.log(articles[0])
}).catch(err => console.log(err))
}, PORT)
app.listen(PORT, () => console.log('server running'))
Additionally, I have not found any API or RSS feed I can use to obtain updates.