UNPKG

sanuwa-npm

Version:

npm package for sanuwa-api

36 lines (32 loc) 1.19 kB
const qs = require('qs') const cheerio = require('cheerio') const axios = require('axios') const { default: Axios } = require('axios') const cookie = require('cookie') const fetch = require('node-fetch') const FormData = require('form-data') function twitter(url) { return new Promise((resolve, reject) => { let params = new URLSearchParams() params.append('URL', url) fetch('https://twdown.net/download.php', { method: 'POST', body: params }) .then(res => res.text()) .then(res => { const $ = cheerio.load(res); data = [] $('div.container').find('tbody > tr > td').each(function (index, element) { x = $(this).find('a').attr('href') if (x !== '#') { if (typeof x !== 'undefined') { data.push({ url: x }) } } }) if (data.length == 0) return resolve({ status: false }) resolve({ status: true, data }) }).catch(reject) }) } module.exports = twitter;