Created
March 17, 2024 09:27
-
-
Save mustofa-id/0a2a035dc8dee6d197050c27c9ffb59e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const total = 1_000; | |
const limit = 40; | |
const messages = []; | |
let ok = 0; | |
let fail = 0; | |
async function send() { | |
try { | |
// copy from chrome dev-tools | |
const res = await fetch("https://dgety-ld.jxh.my.id/ast/req/2f68d4e0d386ee468cd061afc288d287.php", { | |
"headers": { "content-type": "application/x-www-form-urlencoded" }, | |
"body": "pin1=I&pin2=D&pin3=I&pin4=O&pin5=T&pin6=T", | |
"method": "POST" | |
}); | |
if (res.ok) { ok++ } else { | |
throw new Error(`(${res.status}) ${res.statusText}`) | |
}; | |
} catch (e) { | |
fail++; | |
messages.push(e.message) | |
} | |
process.stdout.write(` 🚀 ok: ${ok} | fail: ${fail} | last fail message: "${messages.at(-1)}"\r`); | |
} | |
async function breathe() { | |
process.stdout.write(` ⏳\r`); | |
await new Promise((r) => setTimeout(r, 5_000)); | |
} | |
console.log(`sending ${total} requests in ${total/limit} batches...`); | |
for (let i = 0; i < total/limit; i++) { | |
if (i !== 0) await breathe(); | |
await Promise.all(Array.from({ length: limit }).map(send)); | |
} | |
console.log('\ndone'); |
Author
mustofa-id
commented
Mar 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment