mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
feat(route): add dnaindia (#12941)
* feat(route): add dnaindia * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/dnaindia/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/dnaindia/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/dnaindia/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update<category.js>: change logger and item.category * Update traditional-media.md * Update lib/v2/dnaindia/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/dnaindia/category.js ---------
This commit is contained in:
@@ -242,6 +242,36 @@ Support all channels, refer to [CNBC RSS feeds](https://www.cnbc.com/rss-feeds/)
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## DNA India
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn auther="Rjnishant530" example="/dnaindia/headlines" path="/dnaindia/:category" :paramsDesc="['Find it in the URL, or tables below']" radar="1">
|
||||
|
||||
Categories:
|
||||
|
||||
| Headlines | Explainer | India | Entertainment | Sports | Viral | Lifestyle | Education | Business | World |
|
||||
| --------- | --------- | ----- | ------------- | ------ | ----- | --------- | --------- | -------- | ----- |
|
||||
| headlines | explainer | india | entertainment | sports | viral | lifestyle | education | business | world |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Topic
|
||||
|
||||
<RouteEn auther="Rjnishant530" example="/dnaindia/topic/dna-verified" path="/dnaindia/topic/:topic" :paramsDesc="['Find it in the URL']" radar="1">
|
||||
|
||||
Topics:
|
||||
|
||||
|DNA verified|
|
||||
|------------|
|
||||
|dna-verified|
|
||||
|
||||
::: tip Topic
|
||||
See the URL for `https://www.dnaindia.com/topic/dna-verified` for the subdomain `topic`
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Financial Times
|
||||
|
||||
### myFT personal RSS
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const logger = require('@/utils/logger');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { category, topic } = ctx.params;
|
||||
const baseUrl = 'https://www.dnaindia.com';
|
||||
let route;
|
||||
if (category) {
|
||||
route = `/${category}`;
|
||||
} else if (topic) {
|
||||
route = `/topic/${topic}`;
|
||||
} else {
|
||||
logger.error('Invalid URL');
|
||||
}
|
||||
const { data: response } = await got(`${baseUrl}${route}`);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const listItems = $('div.col-lg-6 div.list-news')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const a = item.find('div.explainer-subtext a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: `${baseUrl}${a.attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
listItems.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
item.itunes_item_image = $('div.article-img img').attr('src');
|
||||
item.category = $('div.tags ul li')
|
||||
.toArray()
|
||||
.map((item) => $(item).find('a').text());
|
||||
const time = $('p.dna-update').text().split('Updated:')[1];
|
||||
item.pubDate = timezone(parseDate(time, 'MMMDD,YYYY,hh:mmA'), +5.5);
|
||||
item.author = 'DNA Web Team';
|
||||
item.description = $('div.article-description')
|
||||
.clone()
|
||||
.children('div')
|
||||
.remove()
|
||||
.end()
|
||||
.toArray()
|
||||
.map((element) => $(element).html())
|
||||
.join('');
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'DNA India',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
description: 'Latest News on dnaIndia.com',
|
||||
logo: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico',
|
||||
icon: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/:category': ['Rjnishant530'],
|
||||
'/topic/:topic': ['Rjnishant530'],
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'dnaindia.com': {
|
||||
_name: 'DNA India',
|
||||
'.': [
|
||||
{
|
||||
title: 'News',
|
||||
docs: 'https://docs.rsshub.app/en/traditional-media.html#dna-india',
|
||||
source: ['/:category'],
|
||||
target: '/dnaindia/:category',
|
||||
},
|
||||
{
|
||||
title: 'Topic',
|
||||
docs: 'https://docs.rsshub.app/en/traditional-media.html#dna-india',
|
||||
source: ['/topic/:topic'],
|
||||
target: '/dnaindia/topic/:topic',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:category', require('./category'));
|
||||
router.get('/topic/:topic', require('./category'));
|
||||
};
|
||||
Reference in New Issue
Block a user