feat(route): add AppleInsider (#10040)
* feat(route): add AppleInsider * fix: punctuation
This commit is contained in:
@@ -41,6 +41,18 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
|
||||
|
||||
<RouteEn author="nczitzk" example="/aflcio/blog" path="/aflcio/blog"/>
|
||||
|
||||
## AppleInsider
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="nczitzk" example="/appleinsider" path="/appleinsider/:category?" :paramsDesc="['Category, see below, News by default']">
|
||||
|
||||
| News | Reviews | How-tos |
|
||||
| ---- | ------- | ------- |
|
||||
| | reviews | how-to |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## ASML Holding N.V.
|
||||
|
||||
### Press releases & announcements
|
||||
|
||||
@@ -138,6 +138,18 @@ pageClass: routes
|
||||
|
||||
<Route author="nczitzk" example="/aljazeera/news" path="/aljazeera/news"/>
|
||||
|
||||
## AppleInsider
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/appleinsider" path="/appleinsider/:category?" :paramsDesc="['分类,见下表,默认为空,即 News']">
|
||||
|
||||
| News | Reviews | How-tos |
|
||||
| ---- | ------- | ------- |
|
||||
| | reviews | how-to |
|
||||
|
||||
</Route>
|
||||
|
||||
## ASML 阿斯麦
|
||||
|
||||
### Press releases & announcements
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
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://appleinsider.com';
|
||||
const currentUrl = `${rootUrl}${category ? `/${category}` : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $(`${category === '' ? '#news-river ' : ''}.river`)
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item).find('a').first();
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('#article-social').next().remove();
|
||||
content('#article-hero, #article-social').remove();
|
||||
content('.deals-widget').remove();
|
||||
|
||||
item.title = content('.h1-adjust').text();
|
||||
item.author = content('.avatar-link a').attr('title');
|
||||
item.pubDate = parseDate(content('time').first().attr('datetime'));
|
||||
item.description = content('header').next('.row').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'appleinsider.com': {
|
||||
_name: 'AppleInsider',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#appleinsider-fen-lei',
|
||||
source: ['/:category', '/'],
|
||||
target: '/appleinsider/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user