A library that scrapes events from Kuksa's event listing using Puppeteer.
You can install the library using npm install kuksa-event-scraper
If the installation fails due to missing libraries, try installing Chrome/Chromium using your OS's package manager and then try again. This ensures all the necessary libraries for building Chrome/Chromium are available on your machine.
const kuksa = require('kuksa-event-scraper');
(async () => {
const eventIds = await kuksa.getEvents({
organizer: 9999426, // ID of organizer (optional)
});
console.log(eventIds); // Prints ids of matching events, e.g. [123, 234]
const eventInfo = await kuksa.getEventInfo(123);
console.log(eventInfo); // Prints an object representing the event
})()
Returns the ids of the events matching the filters as an array, e.g.
[
27956,
28052,
27466
]
If filter is not given, returns all events.
The available filters are:
{
organizer: 9999426, // id of the organizer, e.g. troop (optional)
dateStart: new Date(), // only list events starting after this date (optional)
dateEnd: new Date(), // only list events before this date (optional)
}
You can combine different filters as you like. You can find the available organiser ids for example by inspecting the event search organiser dropdown with developer tools.
Returns the details of an event, e.g.
{ id: 12312, // same as the id you gave
name: 'Kesäleiri 2017',
organizer: 'Matinkylän Mallikkaat ry',
dateTimeStarts: new Date('2017-07-21T09:00:00.000Z'),
dateTimeEnds: new Date('2017-07-27T09:00:00.000Z'),
onlyDatesAvailable: true, // true if the exact starting and ending time is not available
registrationEnds: new Date('2017-06-14T09:00:00.000Z'),
lateRegistrationEnds: new Date('2017-07-14T09:00:00.000Z'),
location: 'Mallikkalan Leirialue',
eventType: 'Leiri (väh. 3 yötä)',
ageGroup: 'Seikkailijat', // age group, if available
descriptionText: 'Leirillä on luvassa kivaa puuhaa',
descriptionHTML: '<span style="font-size: 13.3333px;">Leirillä on luvassa <b>kivaa puuhaa</b></span>' }
If an event with the given id is not found, returns null
.
Allows you to set the options passed to puppeteer.launch()
. You should rarely be needing this. In Heroku you may need to pass { args: ['--no-sandbox'] }
to this function before any other calls to get Puppeteer running.