-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
1 parent
d2d3472
commit 4fb2b3e
Showing
12 changed files
with
563 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Público', | ||
url: 'publico.es', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} |
Oops, something went wrong.