You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
878 B
JavaScript

import axios from 'axios';
import { attr, api } from '../config.js';
import { parse } from 'node-html-parser';
export async function getLastest(req, res) {
try {
const { data } = await axios.get(api.home);
const html = parse(data);
res.json(
html
.querySelectorAll('.row.row-cols-5 .col.col-md-6.col-lg-2.col-6')
.map((i) => {
const id = attr(i, 'a', 'href').split('/').pop();
return {
id: id || null,
title: i.querySelector('.animetitles')?.text || null,
image: attr(i, '.animeimghv', 'data-src') || null,
type: i.querySelector('.positioning button').text.trim() || null,
no: parseInt(i.querySelector('.positioning h5').text.trim() || '0') || null,
};
})
);
} catch (error) {
res.status(500).json({ message: error.message });
}
}