Skip to content

Instantly share code, notes, and snippets.

@lizzybrooks
Created April 30, 2024 23:07
Show Gist options
  • Save lizzybrooks/f0ea08f6580eeeb7197d1dd2208e3abb to your computer and use it in GitHub Desktop.
Save lizzybrooks/f0ea08f6580eeeb7197d1dd2208e3abb to your computer and use it in GitHub Desktop.
const axios = require('axios');
const cheerio = require('cheerio');
async function fetchAndParseURL(url) {
try {
const response = await axios.get(url);
const $ = cheerio.load(response.data);
const eventsToday = [];
$('.fsCalendarToday .fsCalendarEventTitle').each((i, elem) => {
eventsToday.push($(elem).text().trim());
});
console.log('Events for today:', eventsToday);
} catch (error) {
console.error('Error fetching or parsing the page:', error);
}
}
// Replace 'http://example.com' with the actual URL
fetchAndParseURL('https://www.lwhs.org/calendar1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment