diff --git a/.gitignore b/.gitignore index 4e8ce6e..5a65d75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -options.json \ No newline at end of file +options.json +results.json \ No newline at end of file diff --git a/options.json.example b/options.json.example index 119d3ab..fa6d516 100644 --- a/options.json.example +++ b/options.json.example @@ -1,3 +1,5 @@ { - "uberPhoneNumber": "1234567891" + "uberPhoneNumber": "1234567891", + "startDateIso": "2023-01-01", + "endDateIso": "2023-12-31" } diff --git a/src/index.js b/src/index.js index 06c20a3..56b426f 100644 --- a/src/index.js +++ b/src/index.js @@ -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