Print to file

This commit is contained in:
PAlexanderFranklin 2023-08-31 22:41:48 -07:00
parent c722fd3483
commit 64ff788ff6
3 changed files with 15 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
options.json
options.json
results.json

View File

@ -1,3 +1,5 @@
{
"uberPhoneNumber": "1234567891"
"uberPhoneNumber": "1234567891",
"startDateIso": "2023-01-01",
"endDateIso": "2023-12-31"
}

View File

@ -7,6 +7,9 @@ function sleep(ms) {
}
async function main() {
let options = JSON.parse(fs.readFileSync("./options.json", "utf8"))
if (!fs.existsSync("./results.json")) {
fs.writeFileSync("./results.json", "")
}
const browser = await puppeteer.launch({
headless: false,
ignoreHTTPSErrors: true,
@ -75,8 +78,8 @@ async function main() {
{
method: "POST",
body: JSON.stringify({
startDateIso: "2023-04-01",
endDateIso: "2023-04-31",
startDateIso: options.startDateIso ?? "2023-04-01",
endDateIso: options.endDateIso ?? "2023-04-31",
paginationOption,
}),
headers: usefulRequestHeaders,
@ -84,11 +87,11 @@ async function main() {
)
let body = await res.json()
body.data.activities.map((activity) => {
console.log(
new Date(activity.recognizedAt * 1000),
activity.formattedTotal,
activity.routing,
)
delete activity.routing
if (activity.tripMetaData?.mapUrl) {
delete activity.tripMetaData.mapUrl
}
fs.appendFileSync("./results.json", JSON.stringify(activity))
})
if (!body.data.pagination.hasMoreData) {
break