From eaf72004a31d0fedffdee23b8faf10fda045b4a8 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 21 Sep 2022 19:03:33 +0200 Subject: [PATCH] feat(route): indiansinkuwait (#10855) * feat(route): indiansinkuwait * docs: fix case --- docs/en/new-media.md | 6 ++++ docs/new-media.md | 2 +- lib/v2/indiansinkuwait/latest.js | 43 ++++++++++++++++++++++++++++ lib/v2/indiansinkuwait/maintainer.js | 3 ++ lib/v2/indiansinkuwait/radar.js | 13 +++++++++ lib/v2/indiansinkuwait/router.js | 3 ++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 lib/v2/indiansinkuwait/latest.js create mode 100644 lib/v2/indiansinkuwait/maintainer.js create mode 100644 lib/v2/indiansinkuwait/radar.js create mode 100644 lib/v2/indiansinkuwait/router.js diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 84ada12e3..fb8c7628c 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -382,6 +382,12 @@ Provides a better reading experience (full text articles) over the official one. +## Indians in Kuwait + +### News + + + ## Institute of International Education ### Blog diff --git a/docs/new-media.md b/docs/new-media.md index 04f54eaa0..5ecbcfd81 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1413,7 +1413,7 @@ Supported sub-sites: -## web3caff +## Web3Caff ### 发现 diff --git a/lib/v2/indiansinkuwait/latest.js b/lib/v2/indiansinkuwait/latest.js new file mode 100644 index 000000000..a588bff9f --- /dev/null +++ b/lib/v2/indiansinkuwait/latest.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const baseUrl = 'https://www.indiansinkuwait.com'; + +module.exports = async (ctx) => { + const { data: response } = await got(`${baseUrl}/latest-news`); + const $ = cheerio.load(response); + + const list = $('.paragraphs .span4') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('.content-heading h6 a').text().trim(), + link: baseUrl + item.find('a').attr('href'), + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + + item.pubDate = parseDate($('#ctl00_ContentPlaceHolder1_SpanAuthor').text()); + $('#newsdetails h3, #ctl00_ContentPlaceHolder1_SpanAuthor, .noprint, [id^=div-gpt-ad]').remove(); + item.description = $('#newsdetails').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text(), + description: $('head meta[name="description"]').attr('content'), + image: 'https://www.indiansinkuwait.com/apple-touch-icon-152x152-precomposed.png', + link: `${baseUrl}/latest-news`, + item: items, + }; +}; diff --git a/lib/v2/indiansinkuwait/maintainer.js b/lib/v2/indiansinkuwait/maintainer.js new file mode 100644 index 000000000..97e4c708d --- /dev/null +++ b/lib/v2/indiansinkuwait/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest': ['TonyRL'], +}; diff --git a/lib/v2/indiansinkuwait/radar.js b/lib/v2/indiansinkuwait/radar.js new file mode 100644 index 000000000..c81c3b3bd --- /dev/null +++ b/lib/v2/indiansinkuwait/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'indiansinkuwait.com': { + _name: 'Indians in Kuwait', + '.': [ + { + title: 'News', + docs: 'https://docs.rsshub.app/en/new-media.html#indians-in-kuwait', + source: ['/latest-news', '/'], + target: '/indiansinkuwait/latest', + }, + ], + }, +}; diff --git a/lib/v2/indiansinkuwait/router.js b/lib/v2/indiansinkuwait/router.js new file mode 100644 index 000000000..f70796a86 --- /dev/null +++ b/lib/v2/indiansinkuwait/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/latest', require('./latest')); +};