Add some things lol

This commit is contained in:
PAlexanderFranklin 2023-08-30 16:24:08 -07:00
parent 51802893b1
commit 15cc89bb00

View File

@ -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 {