This is my first post here, hope I dont violate any rules. I am trying to scrape the word "fed" from https://www.marketwatch.com/economy-politics/calendar I can scrape all , but how can I add only get data which has the word "fed" in it?
This is the code so far.
const PORT = 3000
const express = require('express')
const axios = require('axios')
const cheerio = require('cheerio')
const app = express()
const fedTimes = []
app.get('/', (req,res) => {
res.json('Welcome to Fed Speech Times')
})
app.get('/fed', (req, res) => {
axios.get('https://www.marketwatch.com/economy-politics/calendar')
.then((response) => {
const html = response.data
const $ = cheerio.load(html)
$('td', html).each(function() {
const title = $(this).text()
fedTimes.push({
title
})
})
res.json(fedTimes)
}).catch((err) => console.log(err))
})
app.listen(PORT, () => console.log(`server running on PORT ${PORT}`))