closes #412 http://www.dongqiudi.com/archive/751923.html 今天的早报链接居然还是404的,坑死我了。
This commit is contained in:
@@ -200,6 +200,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- 起点
|
||||
- 章节
|
||||
- 讨论区
|
||||
- 懂球帝
|
||||
- 早报
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -1626,3 +1626,13 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
|
||||
路由: `/qidian/forum/:id`
|
||||
|
||||
参数: id,小说 id,可在对应小说页 URL 中找到
|
||||
|
||||
## 懂球帝
|
||||
|
||||
### 早报
|
||||
|
||||
举例: [https://rsshub.app/dongqiudi/daily](https://rsshub.app/dongqiudi/daily)
|
||||
|
||||
路由: `/dongqiudi/daily`
|
||||
|
||||
参数:无
|
||||
|
||||
@@ -372,4 +372,7 @@ router.get('/keep/user/:id', require('./routes/keep/user'));
|
||||
router.get('/qidian/chapter/:id', require('./routes/qidian/chapter'));
|
||||
router.get('/qidian/forum/:id', require('./routes/qidian/forum'));
|
||||
|
||||
// 懂球帝
|
||||
router.get('/dongqiudi/daily', require('./routes/dongqiudi/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const config = require('../../config');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const _axios_client = axios.create({
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await _axios_client.get('http://www.dongqiudi.com/special/48');
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const host = 'http://www.dongqiudi.com';
|
||||
|
||||
const list = $('.detail.special ul li h3').slice(0, 10);
|
||||
const out = [];
|
||||
const proList = [];
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const $ = cheerio.load(list[i]);
|
||||
const title = $('a').text();
|
||||
const itemUrl = host + $('a').attr('href');
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
out.push(JSON.parse(cache));
|
||||
continue;
|
||||
}
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
};
|
||||
|
||||
try {
|
||||
const es = _axios_client.get(itemUrl);
|
||||
proList.push(es);
|
||||
out.push(single);
|
||||
} catch (err) {
|
||||
console.log(`${title}: ${itemUrl} -- ${err.response.status}: ${err.response.statusText}`);
|
||||
}
|
||||
}
|
||||
|
||||
const responses = await axios.all(proList);
|
||||
for (let i = 0; i < responses.length; i++) {
|
||||
const $ = cheerio.load(responses[i].data);
|
||||
const full = $('div.detail');
|
||||
|
||||
out[i].description = full.find('div:nth-of-type(1)').html();
|
||||
out[i].author = full.find('span.name').text();
|
||||
out[i].pubDate = new Date(full.find('span.time').text()).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: '懂球帝早报',
|
||||
link: 'http://www.dongqiudi.com/special/48',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user