Created
February 21, 2021 17:32
-
-
Save tannerkrewson/39e69dee88866eb292715490790a7b00 to your computer and use it in GitHub Desktop.
equinox price scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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