mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
fix(route): 东莞教研网 (#10102)
* fix(route): 东莞教研网 * fix: external links * docs: move to study
This commit is contained in:
@@ -405,18 +405,6 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<Route author="DIYgod" example="/dida365/habit/checkins" path="/dida365/habit/checkins" selfhost="1"/>
|
||||
|
||||
## 东莞教研网
|
||||
|
||||
### 信息公开
|
||||
|
||||
<Route author="nczitzk" example="/dgjyw/news" path="/dgjyw/:type" :paramsDesc="['分类']">
|
||||
|
||||
| 动态 | 公示 | 通知 |
|
||||
| ---- | ------------ | ------ |
|
||||
| news | announcement | notice |
|
||||
|
||||
</Route>
|
||||
|
||||
## 福利资源 - met.red
|
||||
|
||||
### 福利资源 - met.red
|
||||
|
||||
@@ -248,6 +248,28 @@ path="/ctfhub/upcoming/:limit?"
|
||||
|
||||
</Route>
|
||||
|
||||
## 东莞教研网
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/dgjyw/tz" path="/dgjyw/:category?" :paramsDesc="['分类,见下表,默认为通知']">
|
||||
|
||||
| 通知 | 动态 | 公示 |
|
||||
| -- | -- | -- |
|
||||
| tz | dt | gs |
|
||||
|
||||
::: tip 提示
|
||||
|
||||
分类字段处填写的是对应东莞教研网网址中中介于 **<https://www.dgjyw.com/>** 和 **.htm** 中间的一段。
|
||||
|
||||
如 [通知](https://www.dgjyw.com/tz.htm) 的网址为 <https://www.dgjyw.com/tz.htm>,其中间字段为 `tz`,所以可得路由为 [`/dgjyw/tz`](https://rsshub.app/dgjyw/tz);
|
||||
|
||||
同理,[教育科研 - 科研文件](https://www.dgjyw.com/jyky/kywj.htm) 的网址为 <https://www.dgjyw.com/jyky/kywj.htm>,其中间字段为 `jyky/kywj`,所以可得路由为 [`/dgjyw/jyky/kywj`](https://rsshub.app/dgjyw/jyky/kywj)。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 杭州市国家普通话测试网报信息
|
||||
|
||||
### 考试信息
|
||||
|
||||
+1
-1
@@ -2863,7 +2863,7 @@ router.get('/law/jctd', lazyloadRouteHandler('./routes/law/jctd'));
|
||||
router.get('/samsungmembers/latest', lazyloadRouteHandler('./routes/samsungmembers/latest'));
|
||||
|
||||
// 东莞教研网
|
||||
router.get('/dgjyw/:type', lazyloadRouteHandler('./routes/dgjyw/index'));
|
||||
// router.get('/dgjyw/:type', lazyloadRouteHandler('./routes/dgjyw/index'));
|
||||
|
||||
// 中国信息通信研究院
|
||||
router.get('/gov/caict/bps', lazyloadRouteHandler('./routes/gov/caict/bps'));
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const rootUrl = 'http://zxls.dgjyw.com/';
|
||||
|
||||
const config = {
|
||||
news: {
|
||||
link: '/node/57620',
|
||||
title: '动态',
|
||||
},
|
||||
announcement: {
|
||||
link: '/node/57725',
|
||||
title: '公示',
|
||||
},
|
||||
notice: {
|
||||
link: '/node/57621',
|
||||
title: '通知',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cfg = config[ctx.params.type];
|
||||
if (!cfg) {
|
||||
throw Error('Bad category. See <a href="https://docs.rsshub.app/other.html#dong-guan-jiao-yan-wang">docs</a>');
|
||||
}
|
||||
|
||||
const currentUrl = url.resolve(rootUrl, cfg.link);
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('ul.list-ul')
|
||||
.eq(2)
|
||||
.find('li')
|
||||
.slice(0, 20)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a[title]');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
pubDate: new Date(new Date().getFullYear().toString().substr(0, 2) + item.find('span').text()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
|
||||
item.description = content('div.text').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '东莞教研网 - ' + cfg.title,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const params = ctx.path;
|
||||
|
||||
const rootUrl = 'https://www.dgjyw.com';
|
||||
const currentUrl = `${rootUrl}${params === '/' ? '/tz' : params}.htm`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('div.text-list ul li a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${/^http/.test(link) ? '' : `${rootUrl}/`}${link}`,
|
||||
pubDate: parseDate(item.next().text()),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (/dgjyw\.com/.test(item.link)) {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
https: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.cont-tit').remove();
|
||||
content('.art-body').html(content('.v_news_content').html());
|
||||
|
||||
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8);
|
||||
item.description = content('form[name="_newscontent_fromname"]').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 = {
|
||||
'dgjyw.com': {
|
||||
_name: '东莞教研网',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/other.html#dong-guan-jia-yan-wang-fen-lei',
|
||||
source: ['/'],
|
||||
target: (params, url) => `/dgjyw/${new URL(url).toString().match(/dgjyw\.com\/(.*)\.htm$/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get(/([\w\d/-]+)?/, require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user