UNPKG

notmebotz-tools

Version:

Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT

55 lines (49 loc) 1.28 kB
const axios = require('axios'); const up = require('../../lib/uploadFile'); async function sswebs(url, type = "desktop") { try { const headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'Cache-Control': 'no-cache' }; const postData = { url: url, device: type, fullPage: false }; const response = await axios.post('https://api.magickimg.com/generate/website-screenshot', postData, { headers: headers, responseType: 'arraybuffer' }); if (response.status === 200) { const buffer = Buffer.from(response.data, 'binary'); const url = await up(buffer); return { author: "Herza", status: 200, data: { img_url: url } }; } else { return { author: "Herza", status: 400, data: { message: 'Failed to capture screenshot' } }; } } catch (error) { return { author: "Herza", status: 500, data: { message: error.message } }; } } module.exports = { sswebs }