feat(route): add Europa Press (#7943)

Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
Ethan Shen
2021-08-12 01:15:44 -07:00
committed by GitHub
co-authored by NeverBehave
parent 9bc0401962
commit 37877a93fe
4 changed files with 135 additions and 0 deletions
+40
View File
@@ -163,6 +163,46 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
</RouteEn>
## Europa Press
### Category
<RouteEn author="nczitzk" example="/europapress" path="/europapress/:category?" :paramsDesc="['Category, see below, Home by default']">
| España | Internacional | Economía | Deportes |
| -------- | ------------- | -------- | -------- |
| nacional | internacional | economía | deportes |
| Cultura | Sociedad | Ciencia | Salud |
| ------- | -------- | ------- | ----- |
| cultura | sociedad | ciencia | salud |
| Tecnología | Comunicados | Estar donde estés |
| ---------- | ----------- | ----------------- |
| tecnología | comunicados | estar-donde-estes |
| Andalucía | Aragón | Cantabria | Castilla-La Mancha |
| --------- | ------ | --------- | ------------------ |
| andalucia | aragon | cantabria | castilla-lamancha |
| Castilla y León | Cataluña | Extremadura | Galicia |
| --------------- | --------- | ----------- | ------- |
| castilla-y-leon | catalunya | extremadura | galicia |
| Islas Canarias | Islas Baleares | Madrid | País Vasco |
| -------------- | -------------- | ------ | ---------- |
| islas-canarias | illes-balears | madrid | euskadi |
| La Rioja | C. Valenciana | Navarra | Asturias |
| -------- | -------------------- | ------- | -------- |
| la-rioja | comunitat-valenciana | navarra | asturias |
| Murcia | Ceuta y Melilla |
| ------ | --------------- |
| murcia | ceuta-y-melilla |
</RouteEn>
## ezone.hk
### Category
+40
View File
@@ -224,6 +224,46 @@ pageClass: routes
<Route author="nczitzk" example="/esquirehk/tag/Fashion" path="/esquirehk/tag/:id" :paramsDesc="['标签,可在对应标签页 URL 中找到']" />
## Europa Press
### 分类
<Route author="nczitzk" example="/europapress" path="/europapress/:category?" :paramsDesc="['分类,见下表,默认为首页']">
| España | Internacional | Economía | Deportes |
| -------- | ------------- | -------- | -------- |
| nacional | internacional | economía | deportes |
| Cultura | Sociedad | Ciencia | Salud |
| ------- | -------- | ------- | ----- |
| cultura | sociedad | ciencia | salud |
| Tecnología | Comunicados | Estar donde estés |
| ---------- | ----------- | ----------------- |
| tecnología | comunicados | estar-donde-estes |
| Andalucía | Aragón | Cantabria | Castilla-La Mancha |
| --------- | ------ | --------- | ------------------ |
| andalucia | aragon | cantabria | castilla-lamancha |
| Castilla y León | Cataluña | Extremadura | Galicia |
| --------------- | --------- | ----------- | ------- |
| castilla-y-leon | catalunya | extremadura | galicia |
| Islas Canarias | Islas Baleares | Madrid | País Vasco |
| -------------- | -------------- | ------ | ---------- |
| islas-canarias | illes-balears | madrid | euskadi |
| La Rioja | C. Valenciana | Navarra | Asturias |
| -------- | -------------------- | ------- | -------- |
| la-rioja | comunitat-valenciana | navarra | asturias |
| Murcia | Ceuta y Melilla |
| ------ | --------------- |
| murcia | ceuta-y-melilla |
</Route>
## ezone.hk
### 分类
+2
View File
@@ -4158,6 +4158,8 @@ router.get('/tanchinese/:category?', require('./routes/tanchinese'));
// Harvard
router.get('/harvard/health/blog', require('./routes/universities/harvard/health/blog'));
// Europa Press
router.get('/europapress/:category?', require('./routes/europapress'));
// World Happiness Report
router.get('/worldhappiness/blog', require('./routes/worldhappiness/blog'));
router.get('/worldhappiness/archive', require('./routes/worldhappiness/archive'));
+53
View File
@@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category || '';
const rootUrl = 'https://www.europapress.es';
const currentUrl = `${rootUrl}${category ? `/${category}` : ''}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.articulo-titulo, .c-item__title, .home-articulo-titulo')
.find('a')
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('.full644').html() + content('.NormalTextoNoticia').html();
item.pubDate = parseDate(content('meta[name="date"]').attr('content').replace(' ', ''));
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};