Skip to content

Instantly share code, notes, and snippets.

@tannerkrewson
Created February 21, 2021 17:32
Show Gist options
  • Save tannerkrewson/39e69dee88866eb292715490790a7b00 to your computer and use it in GitHub Desktop.
Save tannerkrewson/39e69dee88866eb292715490790a7b00 to your computer and use it in GitHub Desktop.
equinox price scraper
const https = require("https");
const getInfo = (i) =>
new Promise((resolve, reject) => {
https
.get("https://api.equinox.com/v6/acq/residential/plans/" + i, (resp) => {
let data = "";
resp.on("data", (chunk) => {
data += chunk;
});
resp.on("end", () => {
const {
success,
region,
accessFacility,
clubName,
result,
} = JSON.parse(data);
if (success && region === "New York") {
resolve({
accessFacility,
clubName,
prices: result.map(
({ planProperties }) => planProperties.monthlyFee
),
});
} else {
resolve();
}
});
})
.on("error", (err) => {
console.log("Error: " + err.message);
reject(err);
});
});
const [start, end] = [102, 155];
const reqs = [];
for (let i = start; i <= end; i++) {
reqs.push(getInfo(i));
}
Promise.all(reqs).then((x) => {
console.log(x);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment