From 15cc89bb0004b5cf3642d6c7f4c19e70f8b8e875 Mon Sep 17 00:00:00 2001 From: PAlexanderFranklin Date: Wed, 30 Aug 2023 16:24:08 -0700 Subject: [PATCH] Add some things lol --- index.js | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 3ca4d05..effc8f1 100644 --- a/index.js +++ b/index.js @@ -14,12 +14,12 @@ const settlePromises = async (promiseArray) => { } async function main() { + const browser = await puppeteer.launch({ + headless: false, + ignoreHTTPSErrors: true, + executablePath: "/usr/bin/chromium", + }) try { - const browser = await puppeteer.launch({ - headless: false, - ignoreHTTPSErrors: true, - executablePath: "/usr/bin/chromium", - }) console.log("Opened Browser") const page = await browser.newPage() console.log("Opened Page") @@ -28,41 +28,48 @@ async function main() { let usefulRequestHeaders = {} page.on("request", (request) => { let url = request.url() - console.log("request url", url) if (url.includes("getWebActivityFeed")) { usefulRequestHeaders = { ...request.headers() } console.log("hello!", usefulRequestHeaders) } - request.continue() + if (request.isInterceptResolutionHandled()) { + return + } + + if ( + url.endsWith(".png") || + url.endsWith(".jpg") || + url.endsWith(".ico") + ) { + request.abort() + } else { + console.log("request url", url) + request.continue() + } + }) + + page.on("response", async (response) => { + const request = response.request() + if (request.url().includes("desiredrequest.json")) { + const text = await response.text() + console.log(text) + } }) await page.goto("https://drivers.uber.com/earnings/activities") console.log("Went to Page") - await page.waitForSelector('input[aria-label="Select a date range."]') - console.log("We're in.", usefulRequestHeaders) - - for (let i = 0; i < 10; i++) { + for (let i = 0; i < 100; i++) { await sleep(500) if (usefulRequestHeaders["content-type"]) { console.log("success") break } - if (i == 9) { + if (i == 99) { throw "fail" } } console.log("after sleep loop") - - const response = await fetch("https://www.google.com", { - method: "POST", - headers: usefulRequestHeaders, - body: JSON.stringify({ Request }), - }) - - // if (response.ok) { - // console.log(await response.json()); - // } } catch (err) { console.error("Critical failure", err) } finally {