Compare commits

...

7 Commits

1
.gitignore vendored

@ -1,2 +1,3 @@
node_modules
dist
.prettierignore

@ -1,3 +1,10 @@
import axios from 'axios';
export const maskScrapingHeaders = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
};
const url = 'https://monoschinos2.com';
export const api = {
@ -15,3 +22,7 @@ export const api = {
export function attr(html, selector, attribute = 'src') {
return html.querySelector(selector)?.attributes[attribute];
}
export function get(url) {
return axios.get(url, { headers: { ...maskScrapingHeaders } });
}

@ -1,12 +1,10 @@
import { parse } from 'node-html-parser';
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
export async function getAnimes(req, res) {
try {
let { page = '1' } = req.params;
const { data } = await axios.get(`${api.all(page)}`);
const { data } = await get(`${api.all(page)}`);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {
@ -23,4 +21,3 @@ export async function getAnimes(req, res) {
});
}
}

@ -1,12 +1,11 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getAnime(req, res) {
try {
const url = 'https://monoschinos2.com/';
const { id } = req.params;
const { data } = await axios.get(api.anime(id));
const { data } = await get(api.anime(id));
const html = parse(data);
const date = html.querySelectorAll('.breadcrumb')[1].querySelector('.breadcrumb-item').text;
res.status(200).json({

@ -1,20 +1,16 @@
import { parse } from 'node-html-parser';
import { attr, api } from '../config.js';
import axios from 'axios';
import { attr, api, get } from '../config.js';
export async function getCalendar(req, res) {
try {
const { data } = await axios.get(api.calendar);
const { data } = await get(api.calendar);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain [data-dia]').map((i) => {
const day = i.getAttribute('data-dia');
return {
day,
animes: i
.querySelectorAll('.col-md-6.col-lg-4.col-sm-12.for768')
.map((i) => {
animes: i.querySelectorAll('.col-md-6.col-lg-4.col-sm-12.for768').map((i) => {
return {
id: attr(i, 'a', 'href').split('/').pop() || null,
title: i.querySelector('.serisdtls a h3').text.trim() || null,
@ -23,7 +19,7 @@ export async function getCalendar(req, res) {
}),
};
})
)
);
} catch (error) {
res.status(500).json({ message: error.message });
}

@ -1,11 +1,10 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getEmision(req, res) {
try {
let { page = '1' } = req.query;
const { data } = await axios.get(api.emision(page));
const { data } = await get(api.emision(page));
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {
@ -15,7 +14,7 @@ export async function getEmision(req, res) {
image: attr(i, '.animemainimg') || null,
};
})
)
);
} catch (error) {
res.status(500).json({ message: error.message });
}

@ -1,13 +1,13 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getEpisode(req, res) {
try {
const { id } = req.params;
const { data } = await axios.get(api.episode(id));
const { data } = await get(api.episode(id));
const html = parse(data);
const ctrls = html.querySelectorAll('.controldiv2 a');
let nav = {};
let mapc = ctrls.map((e, i) => {
let elem = e.querySelector('img').classList;
@ -33,7 +33,7 @@ export async function getEpisode(req, res) {
title: html.querySelector('.heromain_h1').text.replace(/Sub\sEspañol/gi, ''),
nextEpisodes: nextEpisodes.length == 0 ? null : nextEpisodes,
ctrs: nav,
sugestions: html.querySelectorAll('.nextplay:nth-child(2) .nextplays a').map((i) => {
sugestions: html.querySelectorAll('.nextplay:nth-child(3) .nextplays a').map((i) => {
const image = attr(i, '.nxtmainimg', 'src');
return {
image: image.length == 0 || !image ? imgNotFound : image,
@ -63,4 +63,3 @@ export async function getEpisode(req, res) {
});
}
}

@ -1,6 +1,5 @@
import axios from 'axios';
import { parse } from 'node-html-parser';
import { api, attr } from '../config.js';
import { api, attr, get } from '../config.js';
export async function filterBy(req, res) {
try {
@ -11,7 +10,7 @@ export async function filterBy(req, res) {
letra = 'false',
pagina = '1',
} = req.query;
const { data } = await axios.get(`${api.filter({ categoria, fecha, genero, letra, pagina })}`);
const { data } = await get(`${api.filter({ categoria, fecha, genero, letra, pagina })}`);
const html = parse(data);
res.status(200).json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {

@ -1,20 +1,17 @@
import axios from 'axios';
import { attr, api } from '../config.js';
import { attr, api, get } from '../config.js';
import { parse } from 'node-html-parser';
export async function getLastest(req, res) {
try {
const { data } = await axios.get(api.home);
const { data } = await 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) => {
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,
image: attr(i, '.animeimgdiv img', 'data-src') || null,
type: i.querySelector('.positioning button').text.trim() || null,
no: parseInt(i.querySelector('.positioning h5').text.trim() || '0') || null,
};

@ -1,12 +1,11 @@
import axios from 'axios';
import { parse } from 'node-html-parser';
import { api, attr } from '../config.js';
import { api, attr, get } from '../config.js';
export async function searchAnime(req, res) {
try {
let { id } = req.params;
let { page = '1' } = req.query;
const { data } = await axios.get(api.search(id, page));
const { data } = await get(api.search(id, page));
const html = parse(data);
res.json(
html.querySelectorAll('.heromain .row .col-md-4.col-lg-2.col-6').map((i) => {

Loading…
Cancel
Save