-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparse.js
More file actions
18 lines (17 loc) · 732 Bytes
/
parse.js
File metadata and controls
18 lines (17 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const JSSoup = require('jssoup').default
const fs = require('fs')
module.exports = {
parse: function(data) {
var soup = new JSSoup(data)
var services = soup.findAll('div','service-wrapper')
return services.map(function(service) {
var name = service.find("h3","service-name").contents + ""
if (name.indexOf("Batteries") > -1) {
return null // doesn't have a next-service due to COVID
}
var next = service.find("td","next-service").contents + ""
var nextDate = next.split("\n")[1].replace(/\t/g,"")
return {"name": name.replace(/\t/g,""), "next": nextDate}
}).filter(function(i) { return i != null })
}
}