src/ss-web.js
/*
New scrape @dann
Screenshot website
⚠ Jangan hapus wm ⚠
Tempel wm kalaian kalau mau di share jadi plugins atau apalah
Kalau error b'arti wen nya lah
Cariin lagi aja webnya, jangan yang ceep!!!
*/
async function screenshot(url, format = "png") {
const axios = (await import("axios")).default
const fs = await import("fs")
const path = await import("path")
try {
const api =
"https://screenshot-api-hqlj.onrender.com/screenshot?url=" +
encodeURIComponent(url) +
"&format=" +
encodeURIComponent(format)
const response = await axios({
url: api,
method: "GET",
headers: {
"User-Agent":
"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36",
Accept: "image/png,image/*,*/*"
},
responseType: "arraybuffer",
timeout: 60000,
validateStatus: () => true
})
if (response.status !== 200) {
return {
status: false,
code: response.status,
error: Buffer.from(response.data).toString()
}
}
const ext =
response.headers["content-type"]?.split("/")[1] ||
format
const fileName =
"screenshot_" +
Date.now() +
"." +
ext
const filePath = path.join(
process.cwd(),
fileName
)
fs.writeFileSync(filePath, response.data)
return {
status: true,
code: response.status,
file: fileName,
path: filePath,
mimeType: response.headers["content-type"],
size: response.data.length,
api
}
} catch (e) {
return {
status: false,
error: e.message
}
}
}
return await screenshot(
"https://webkalian.co.id", // ini url web untuk tes bebas pakai url apa aja
"png" // bisa juga jpg kyknya tadi lupa gw
)
Direct URL
Disalin!