| const express = require('express'); | |
| const axios = require('axios'); | |
| const cheerio = require('cheerio'); | |
| const app = express(); | |
| app.set('json spaces', 4); | |
| const bypass = async (url) => { | |
| const res = await axios.get(url); | |
| const $ = cheerio.load(res.data); | |
| const data = JSON.parse($('#app').attr('data-page')); | |
| return data.props.link.finish.map(item => ({ | |
| name: item.name, | |
| url: item.url | |
| })); | |
| }; | |
| app.use('/', express.static('p')) | |
| app.get('/b', async (req, res) => { | |
| const { url } = req.query; | |
| if (!/https:\/\/link2unlock\.com\/[a-zA-Z0-9]+/g.test(url)) { | |
| return res.json({ success: false, error: 'invalid link' }); | |
| } | |
| const result = await bypass(url); | |
| res.json(result); | |
| }); | |
| app.listen(7860); |