code scrape website https://allinonedownloader.com
// ===============================
// SCRAPER BY Shann Molvyr
// ===============================
import axios from "axios";
import * as cheerio from "cheerio";
import crypto from "crypto";
export async function AIODownloader(url) {
try {
const res = await axios.get("https://allinonedownloader.com", {
headers: {
"user-agent": "Mozilla/5.0"
}
});
const $ = cheerio.load(res.data);
const token = $("#token").val();
const pos = $("#scc").val();
if (!token || !pos) {
throw new Error("Token tidak ditemukan");
}
const key = Buffer.from(token, "hex");
const iv = Buffer.from(
"afc4e290725a3bf0ac4d3ff826c43c10",
"hex"
);
let data = Buffer.from(url, "utf8");
const block = 16;
const mod = data.length % block;
const pad = mod === 0 ? block : block - mod;
data = Buffer.concat([data, Buffer.alloc(pad, 0x00)]);
const cipher = crypto.createCipheriv(
"aes-256-cbc",
key,
iv
);
cipher.setAutoPadding(false);
const encrypted = Buffer.concat([
cipher.update(data),
cipher.final()
]);
const urlhash = encrypted.toString("base64");
const cookie = res.headers["set-cookie"]?.[0];
const response = await axios.post(
"https://allinonedownloader.com" + pos,
new URLSearchParams({
url,
token,
urlhash,
pos
}),
{
headers: {
"content-type":
"application/x-www-form-urlencoded; charset=UTF-8",
cookie,
"user-agent":
"Mozilla/5.0 (Linux; Android 10)",
"x-requested-with": "XMLHttpRequest"
}
}
);
return response.data;
} catch (error) {
throw error;
}
}// ===============================
// CASE BOT WHATSAPP (opsional)
// ===============================
import { AIODownloader } from "./scraper.js";
const prefix = ".";
const command = body.split(" ")[0].toLowerCase();
const args = body.trim().split(/ +/).slice(1);
const url = args[0];
switch (command) {
case prefix + "ig":
case prefix + "tt":
case prefix + "fb":
case prefix + "yt":
if (!url) {
return reply(`Ketik ${command} [link]`);
}
try {
await reply(
"Tunggu sebentar, sedang mengambil data..."
);
const result = await AIODownloader(url);
console.log(result);
reply(
"Proses berhasil! Cek console untuk log data."
);
} catch (e) {
console.log(e);
reply(
"Gagal mengambil data. Pastikan link valid."
);
}
break;
}