1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-01-16 10:21:07 +01:00
Facebook-Events-iCal-Converter/lib/parser.js
2019-10-15 09:22:08 +02:00

27 lines
537 B
JavaScript

const { parse } = require('node-html-parser')
const parseHTML = (html) => {
let data = {}
const root = parse(html)
const eventSummary = root.querySelector('#event_summary')
const timeInfo = eventSummary.querySelector('#event_time_info')
const timeContent = timeInfo.querySelector('[content]')
if (
timeContent &&
timeContent.attributes &&
timeContent.attributes.content
) {
data = {
...data,
time: timeContent.attributes.content.value,
}
}
return data
}
module.exports = parseHTML