Print to file
This commit is contained in:
parent
c722fd3483
commit
64ff788ff6
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
options.json
|
||||
options.json
|
||||
results.json
|
@ -1,3 +1,5 @@
|
||||
{
|
||||
"uberPhoneNumber": "1234567891"
|
||||
"uberPhoneNumber": "1234567891",
|
||||
"startDateIso": "2023-01-01",
|
||||
"endDateIso": "2023-12-31"
|
||||
}
|
||||
|
17
src/index.js
17
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
|
||||
|
Loading…
Reference in New Issue
Block a user