diff --git a/src/index.js b/src/index.js index ff238e0..06c20a3 100644 --- a/src/index.js +++ b/src/index.js @@ -55,7 +55,7 @@ async function main() { `input[id="PHONE_NUMBER_or_EMAIL_ADDRESS"]`, options.uberPhoneNumber ?? "", ) - await page.click('button[type="submit"]'); + await page.click('button[type="submit"]') for (let i = 0; i < 100; i++) { await sleep(500) @@ -68,7 +68,33 @@ async function main() { } } console.log("after sleep loop") - await sleep(50000) + let paginationOption = {} + while (true) { + let res = await fetch( + "https://drivers.uber.com/earnings/api/getWebActivityFeed?localeCode=en", + { + method: "POST", + body: JSON.stringify({ + startDateIso: "2023-04-01", + endDateIso: "2023-04-31", + paginationOption, + }), + headers: usefulRequestHeaders, + }, + ) + let body = await res.json() + body.data.activities.map((activity) => { + console.log( + new Date(activity.recognizedAt * 1000), + activity.formattedTotal, + activity.routing, + ) + }) + if (!body.data.pagination.hasMoreData) { + break + } + paginationOption.cursor = body.data.pagination.nextCursor + } } catch (err) { console.error("Critical failure", err) } finally {