This repository has been archived by the owner on Jan 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scraper.js
147 lines (141 loc) · 4.61 KB
/
scraper.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env node
const axios = require('axios');
const cheerio = require('cheerio');
const fs = require("fs");
const path = require('path');
const nyGovSites = [{
name: "NYS DOH Hospital / FQHC Scheduling COVID-19 Sutphin Health Center",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50501251",
address: {
name: "Sutphin Health Center",
street: "105-04 Sutphin Boulevard",
city: "Queens",
state: "NY",
zip: "11435"
}
},
{
name: "Northwell CoVID-19 Vaccination Program: Nassau County - Lake Success",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50500075",
address: {
name: "Lake Success/New Hyde Park",
street: "1111 Marcus Avenue",
city: "New Hyde Park",
state: "NY",
zip: "11042"
}
},
{
name: "NYS DOH Hospital/FQHC Appointment Scheduling COVID-19 at Nassau University Medical Center",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50500121",
address: {
name: "Nassau University Medical Center",
street: "2201 Hempstead Turnpike",
city: "East Meadow",
state: "NY",
zip: "11554"
}
},
{
name: "Northwell CoVID-19 Vaccination Program: Nassau County - Elmont",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50501190",
address: {
name: "NYRA/Belmont",
street: "2150 Hempstead Turnpike",
city: "Elmont",
state: "NY",
zip: "11053"
}
},
{
name: "FIRST DOSE - NYS DOH Hospital/FQHC Appointment Scheduling COVID-19 at Mount Sinai South Nassau",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50500074",
address: {
name: "Mount Sinai South Nassau",
street: "One Healthy Way",
city: "Oceanside",
state: "NY",
zip: "11598"
},
},
{
name: "NYS COVID Vaccine POD - JAVax - Manhattan, N.Y.",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50502320",
address: {
name: "JAVax Manhattan, N.Y.",
street: "429 11th Avenue",
city: "New York",
state: "NY",
zip: "10018"
}
},
{
name: "Northwell CoVID-19 Vaccination Program: Manhattan - Lenox Hill Hospital",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50501473",
address: {
name: "LHH Einhorn Auditorium",
street: "131 East 76th Street",
city: "New York",
state: "NY",
zip: "10021"
}
},
{
name: "NC Dept. of Health at Nassau Community College CCB",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50500881",
address: {
name: "Nassau Community College",
street: "1 Education Drive",
city: "Garden City",
state: "NY",
zip: "11530"
}
},
{
name: "NCDOH at Yes We Can Community Center",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50501806",
address: {
name: "Yes We Can Community Center",
street: "141 Garden Street",
city: "Westbury",
state: "NY",
zip: "11590"
}
},
{
name: "NYS COVID Vaccine POD - Jones Beach State Park - Field 3",
link: "https://apps.health.ny.gov/doh2/applinks/cdmspr/2/counties?OpID=50502584",
address: {
name: "Jones Beach State Park",
street: "1901 Ocean Parkway",
city: "Wantagh",
state: "NY",
zip: "11793"
}
}];
let promises = [];
for (const site of nyGovSites) {
promises.push(axios.get(site.link).then(res => {
site.events = [];
const $ = cheerio.load(res.data);
const eventsWeb = $(".event-type");
for (const event of eventsWeb) {
const isAvailable = $(event).find("button").text() !== "Event Full";
if (isAvailable) {
site.events.push({
date: new Date($(event).find("div div:contains('Date:'):last").first().text().substring(6) + " UTC"),
time: $(event).find("div div:contains('Time:'):last").first().text().substring(6),
appointments: $(event).find("div div:contains('Appointments Available:'):last").first().text().substring(24),
linkId: $(event).parent().attr("id")
});
}
}
}).catch(err => {
console.error(err.message + ": " + err.config.url);
}));
}
Promise.all(promises).then(() => {
const data = JSON.stringify({ sites: nyGovSites }, null, 2);
const filename = path.join("data", "ny_state.json");
fs.writeFileSync(path.resolve(filename), data);
});