mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 23:59:56 +08:00
feat(route): add ielts (#9217)
* feat: add ielts * feat: ielts suggestion
This commit is contained in:
@@ -81,6 +81,12 @@ path="/ctfhub/upcoming/:limit?"
|
|||||||
|
|
||||||
<Route author="liecn" example="/gradcafe/result/computer" path="/gradcafe/result/:type" :paramsDesc="['按关键词进行搜索,如 computer']"/>
|
<Route author="liecn" example="/gradcafe/result/computer" path="/gradcafe/result/:type" :paramsDesc="['按关键词进行搜索,如 computer']"/>
|
||||||
|
|
||||||
|
## IELTS 雅思
|
||||||
|
|
||||||
|
### 最新消息
|
||||||
|
|
||||||
|
<Route author="zenxds" example="/ielts" path="/ielts"/>
|
||||||
|
|
||||||
## MarginNote
|
## MarginNote
|
||||||
|
|
||||||
### 标签
|
### 标签
|
||||||
|
|||||||
58
lib/v2/ielts/index.js
Normal file
58
lib/v2/ielts/index.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const cheerio = require('cheerio');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const targetUrl = 'https://ielts.neea.cn/allnews?locale=zh_CN';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const browser = await require('@/utils/puppeteer')();
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.evaluateOnNewDocument(() => {
|
||||||
|
const proto = navigator.__proto__;
|
||||||
|
delete proto.webdriver;
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto(targetUrl, {
|
||||||
|
waitUntil: 'networkidle0',
|
||||||
|
});
|
||||||
|
const list = await page.evaluate(() =>
|
||||||
|
window
|
||||||
|
.$('#newsListUl li')
|
||||||
|
.get()
|
||||||
|
.map((elem) => {
|
||||||
|
const $elem = window.$(elem);
|
||||||
|
return {
|
||||||
|
title: $elem.find('a').text(),
|
||||||
|
link: $elem.find('a').attr('href'),
|
||||||
|
pubDate: $elem.find('span').eq(-1).text().replace(/[[\]]/g, '').trim(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
browser.close();
|
||||||
|
|
||||||
|
list.sort((a, b) => parseDate(b.pubDate) - parseDate(a.pubDate));
|
||||||
|
list.forEach((item) => {
|
||||||
|
item.pubDate = timezone(parseDate(item.pubDate), +8);
|
||||||
|
});
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(detailResponse.data);
|
||||||
|
item.description = $('.content').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'IELTS雅思最新消息',
|
||||||
|
link: targetUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/ielts/maintainer.js
Normal file
3
lib/v2/ielts/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/': ['zenxds'],
|
||||||
|
};
|
||||||
13
lib/v2/ielts/radar.js
Normal file
13
lib/v2/ielts/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'neea.cn': {
|
||||||
|
_name: 'IELTS雅思',
|
||||||
|
ielts: [
|
||||||
|
{
|
||||||
|
title: '最新消息',
|
||||||
|
docs: 'https://docs.rsshub.app/study.html#ielts-ya-si',
|
||||||
|
source: ['/allnews'],
|
||||||
|
target: '/ielts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/ielts/router.js
Normal file
3
lib/v2/ielts/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/', require('./index'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user