feat(route): add publico.es (#18242)
* Add new route: Spanish newspaper publico.es * Add new route: Spanish newspaper publico.es (II) * Add new route: Spanish newspaper publico.es (III) * Add new route: Spanish newspaper publico.es (fix) * Add new route: Spanish newspaper publico.es (fixes II)
This commit is contained in:
parent
d2d3472b77
commit
4fb2b3eea0
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/ciencias/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/ciencias',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/ciencias'],
|
||||
target: '/ciencias',
|
||||
},
|
||||
],
|
||||
name: 'Ciencias',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/ciencias/${subsection}` : `${rootUrl}/ciencias`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/culturas/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/culturas',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/culturas'],
|
||||
target: '/culturas',
|
||||
},
|
||||
],
|
||||
name: 'Culturas',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/culturas/${subsection}` : `${rootUrl}/culturas`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/economia/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/economia',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/economia'],
|
||||
target: '/economia',
|
||||
},
|
||||
],
|
||||
name: 'Economia',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/economia/${subsection}` : `${rootUrl}/economia`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/internacional/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/internacional',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/internacional'],
|
||||
target: '/internacional',
|
||||
},
|
||||
],
|
||||
name: 'Internacional',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/internacional/${subsection}` : `${rootUrl}/internacional`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
export default function getItems(data) {
|
||||
const items = data('.category-list li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = data(item);
|
||||
const title = item.find('h2').text();
|
||||
const link = item.find('a').attr('href');
|
||||
const author = item.find('p').text();
|
||||
const image = item.find('picture img').attr('src');
|
||||
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
description: `<img src="${image}" alt="${title}">`,
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/mujer/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/mujer',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/mujer'],
|
||||
target: '/mujer',
|
||||
},
|
||||
],
|
||||
name: 'Mujer',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/mujer/${subsection}` : `${rootUrl}/mujer`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Público',
|
||||
url: 'publico.es',
|
||||
};
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/opinion/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/opinion',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/opinion'],
|
||||
target: '/opinion',
|
||||
},
|
||||
],
|
||||
name: 'Opinión',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/opinion/${subsection}` : `${rootUrl}/opinion`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/politica/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/politica',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/politica'],
|
||||
target: '/politica',
|
||||
},
|
||||
],
|
||||
name: 'Política',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/politica/${subsection}` : `${rootUrl}/politica`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
|
||||
const title = $('.article-section h1').text();
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: `${title} | Público`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/public',
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/public',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/public'],
|
||||
target: '/public',
|
||||
},
|
||||
],
|
||||
name: 'Public',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = `${rootUrl}/public`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: 'public | Público',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/sociedad/:subsection?',
|
||||
parameters: {
|
||||
subsection: {
|
||||
description: "Filter by subsection. Check the subsections available on the newspaper's website.",
|
||||
},
|
||||
},
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/sociedad',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/sociedad'],
|
||||
target: '/sociedad',
|
||||
},
|
||||
],
|
||||
name: 'Sociedad',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { subsection } = ctx.req.param();
|
||||
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = subsection ? `${rootUrl}/sociedad/${subsection}` : `${rootUrl}/sociedad`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: 'Medio Ambiente | Sociedad | Público',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import getItems from './items-processor';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/tremending',
|
||||
categories: ['traditional-media'],
|
||||
example: '/publico/tremending',
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: true,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['publico.es/tremending'],
|
||||
target: '/tremending',
|
||||
},
|
||||
],
|
||||
name: 'Tremending',
|
||||
maintainers: ['adrianrico97'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const rootUrl = 'https://www.publico.es';
|
||||
const currentUrl = `${rootUrl}/tremending`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = load(response.data);
|
||||
|
||||
const items = getItems($);
|
||||
|
||||
return {
|
||||
title: 'Tremending | Público',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue