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

73 lines (63 loc) 1.98 kB
const axios = require('axios'); const cheerio = require('cheerio'); async function igstorydl(url) { try { const verifyResponse = await axios.post('https://snapinsta.to/api/userverify', `url=${encodeURIComponent(url)}`, { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': '*/*', 'X-Requested-With': 'XMLHttpRequest' } } ); if (!verifyResponse.data.success || !verifyResponse.data.token) { throw new Error('Failed to get verification token'); } const token = verifyResponse.data.token; const searchResponse = await axios.post('https://snapinsta.to/api/ajaxSearch', `q=${encodeURIComponent(url)}&t=media&v=v2&lang=en&cftoken=${encodeURIComponent(token)}`, { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': '*/*', 'X-Requested-With': 'XMLHttpRequest' } } ); if (searchResponse.data.status !== 'ok') { throw new Error('Search request failed'); } const htmlContent = searchResponse.data.data; const $ = cheerio.load(htmlContent); const dl_link = []; $('.download-items__btn a').each((index, element) => { downloadLinks.push($(element).attr('href')); }); const thumbnailUrl = []; $('.download-items__thumb img').each((index, element) => { const src = $(element).attr('src'); if (src && !src.includes('/imgs/loader.gif')) { thumbnailLinks.push(src); } else if ($(element).attr('data-src')) { thumbnailLinks.push($(element).attr('data-src')); } }); return { author: "Herza", status: 200, data: { dl_link, thumbnailUrl } }; } catch (error) { console.error('Error:', error.message); return { status: 500, error: error.message }; } } module.exports = { igstorydl }