-
Notifications
You must be signed in to change notification settings - Fork 0
/
beltline.js
43 lines (36 loc) · 1.3 KB
/
beltline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* This file scrapes next month's events
* For Atlanta BeltLine
*/
var axios = require('axios');
var moment = require('moment');
//var fs = require('fs');
//var json2csv = require('json2csv');
var today = new Date;
//console.log('today:' + today);
var firstDate = moment.utc(today).add(1, 'months').startOf('month').format('YYYYMMDD');
//console.log('firstDate: ' + firstDate);
var lastDate = moment.utc(today).add(2, 'months').startOf('month').format('YYYYMMDD');
//console.log('lastDate: ' + lastDate);
var url = `https://atlantabeltline.checkfront.com/reserve/?#D${firstDate}`;
//console.log('url: ' + url);
axios.get(url)
.then(resp => {
processData(resp.data);
});
function processData(data) {
console.log('data: ' + data);
//data shows html for a "Checking availability..."" page
//ie, some redirect page. TODO: Come back to this and make it fixed.
// var parsedData = [];
//data.forEach(event => {
//});
/*
var fields = ['Organizer', 'Title', 'Description', 'URL', 'Location', 'Category', 'Start Date', 'End Date', 'Start Time', 'End Time', 'Free or Paid', 'RSVP Info', 'Age Group', 'Dog Friendly', 'Indoor or Outdoor'];
var csv = json2csv({ data: parsedData, fields: fields });
fs.writeFile('beltline.csv', csv, (err) => {
if (err) throw err;
console.log('file saved');
});
*/
}