Update index.js
Browse files380 unmodified lines381382383384384385386387386387388389390391391393392393394395396397398399400401400401402403404405406407408409410402403404414405406407408409410411412418413414415416417418419420421422380 unmodified lines method: 'POST', body: form, headers: { 'User-Agent': generateRandomUserAgent(), 'User-Agent': generateRandomUserAgent(), 'X-Forwarded-For': generateRandomIP(), ...form.getHeaders()} ...form.getHeaders() } });
let data = await response.json();
const $ = cheerio.load(data?.data); const downloads = []; let downloads = [];
$('.dl-action a').each((index, element) => { const format = $(element).text().trim(); const url = $(element).attr('href'); if (url !== '#') { downloads.push({ format, url }); } });
const convertToMP3 = { url: $('.tw-middle a').attr('href') };
const result = { downloads, convert_to_mp3: convertToMP3 };
const hrefArray = [];
$('a').each((index, element) => { const href = $(element).attr('href'); if (href && href !== '/' && href !== '#') { hrefArray.push(href); downloads.push(href); } });
const result = { downloads };
return { result, hrefArray }; return { result }; } catch (error) { return error; }}
const app = express();app.set('json spaces', 4);app.use(morgan('dev'));index.js+14-18