mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Revert "feat: add top stories route for Associated Press News" (#6707)
This commit is contained in:
@@ -20,10 +20,6 @@ Site
|
||||
|
||||
## AP News
|
||||
|
||||
### Top Stories
|
||||
|
||||
<RouteEn author="zphw" example="/apnews" path="/apnews" />
|
||||
|
||||
### Topics
|
||||
|
||||
<RouteEn author="zoenglinghou" example="/apnews/topics/apf-topnews" path="/apnews/topics/:topic" :paramsDesc="['Topic name,can be found in URL. For example: the topic name of AP Top News [https://apnews.com/apf-topnews](https://apnews.com/apf-topnews) is `apf-topnews`']" radar="1" rssbud="1"/>
|
||||
|
||||
@@ -26,10 +26,6 @@ pageClass: routes
|
||||
|
||||
## AP News
|
||||
|
||||
### 首页头条
|
||||
|
||||
<Route author="zphw" example="/apnews" path="/apnews" />
|
||||
|
||||
### 话题
|
||||
|
||||
<Route author="zoenglinghou" example="/apnews/topics/apf-topnews" path="/apnews/topics/:topic" :paramsDesc="['话题名称,可在 URL 中找到,例如 AP Top News [https://apnews.com/apf-topnews](https://apnews.com/apf-topnews) 的话题为 `apf-topnews`']" radar="1" rssbud="1"/>
|
||||
|
||||
@@ -2496,7 +2496,6 @@ router.get('/gbcc/trust', require('./routes/gbcc/trust'));
|
||||
|
||||
// Associated Press
|
||||
router.get('/apnews/topics/:topic', require('./routes/apnews/topics'));
|
||||
router.get('/apnews', require('./routes/apnews/index'));
|
||||
|
||||
// CBC
|
||||
router.get('/cbc/topics/:topic?', require('./routes/cbc/topics'));
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got.get('https://apnews.com/');
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = [];
|
||||
|
||||
// main story component
|
||||
const main = $('div[data-key=main-story]').first();
|
||||
|
||||
// headline news
|
||||
const headline = {};
|
||||
headline.title = $(main).find('a[data-key=card-headline] h1').first().text();
|
||||
headline.link = 'https://apnews.com' + $(main).find('a[data-key=card-headline]').first().attr('href');
|
||||
list.push(headline);
|
||||
|
||||
// related stories
|
||||
$(main)
|
||||
.find('a[data-key=related-story-link]')
|
||||
.each(function (_, e) {
|
||||
const item = {};
|
||||
item.title = $(e).find('div[data-key=related-story-headline]').first().text();
|
||||
item.link = 'https://apnews.com' + $(e).attr('href');
|
||||
list.push(item);
|
||||
});
|
||||
|
||||
const result = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const content = await got.get(item.link);
|
||||
|
||||
const description = cheerio.load(content.data);
|
||||
const metadata = JSON.parse(description('script[type="application/ld+json"]').html());
|
||||
const featureImageURL = metadata.image;
|
||||
|
||||
item.description = `<img src="${featureImageURL}">`;
|
||||
item.description += description('div[class=Article]')
|
||||
.html()
|
||||
.replace(/ADVERTISEMENT/g, '');
|
||||
item.pubDate = new Date(metadata.datePublished).toISOString();
|
||||
item.author = metadata.author[0];
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Associated Press News',
|
||||
link: 'https://apnews.com/',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user