mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
* add nytimes morning post * add 3dm * add full article * add 3dm doc * lint codes * remove useless packages in yarn.lock * add download
This commit is contained in:
@@ -136,6 +136,10 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- 新闻早报
|
||||
- UU 看书
|
||||
- 小说章节
|
||||
- 3dm
|
||||
- 新闻
|
||||
- 攻略
|
||||
- 下载
|
||||
- 喜马拉雅
|
||||
- 专辑
|
||||
- EZTV
|
||||
|
||||
@@ -1085,6 +1085,32 @@ language,语言,可在 [Trending 页](https://github.com/trending/javascript
|
||||
|
||||
参数: id,小说 id,可在对应小说页 URL 中找到
|
||||
|
||||
## 3dm
|
||||
|
||||
### 新闻
|
||||
|
||||
举例: [https://rsshub.app/3dm/detroitbecomehuman/news](https://rsshub.app/3dm/detroitbecomehuman/news)
|
||||
|
||||
路由: `/3dm/:name/news`
|
||||
|
||||
参数: name,游戏的编号可以在专题页的 url 中找到
|
||||
|
||||
### 攻略
|
||||
|
||||
举例: [https://rsshub.app/3dm/detroitbecomehuman/gl](https://rsshub.app/3dm/detroitbecomehuman/gl)
|
||||
|
||||
路由: `/3dm/:name/gl`
|
||||
|
||||
参数: name,游戏的编号可以在专题页的 url 中找到
|
||||
|
||||
### 下载
|
||||
|
||||
举例: [https://rsshub.app/3dm/detroitbecomehuman/download](https://rsshub.app/3dm/detroitbecomehuman/download)
|
||||
|
||||
路由: `/3dm/:name/download`
|
||||
|
||||
参数: name,游戏的编号可以在专题页的 url 中找到
|
||||
|
||||
## 喜马拉雅
|
||||
|
||||
### 专辑
|
||||
|
||||
@@ -284,6 +284,9 @@ router.get('/nytimes/morning_post', require('./routes/nytimes/morning_post'));
|
||||
// UU看书
|
||||
router.get('/uukanshu/chapter/:uid', require('./routes/uukanshu/chapter'));
|
||||
|
||||
// 3dm
|
||||
router.get('/3dm/:name/:type', require('./routes/3dm/news'));
|
||||
|
||||
// 喜马拉雅
|
||||
router.get('/ximalaya/album/:classify/:id', require('./routes/ximalaya/album'));
|
||||
|
||||
|
||||
118
routes/3dm/news.js
Normal file
118
routes/3dm/news.js
Normal file
@@ -0,0 +1,118 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name;
|
||||
const type = ctx.params.type;
|
||||
const url = `http://www.3dmgame.com/games/${name}/${type}`;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.dowlnewslist a');
|
||||
const items = [];
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let item = $(list[i]);
|
||||
const url = item.attr('href');
|
||||
|
||||
let content = '';
|
||||
const urlBase = url.replace(/.html/, '');
|
||||
let total = 1;
|
||||
|
||||
const value = await ctx.cache.get(url);
|
||||
if (value) {
|
||||
item = value;
|
||||
} else {
|
||||
// 抓取分页
|
||||
for (let j = 1; ; j++) {
|
||||
let response;
|
||||
|
||||
const u = j === 1 ? url : urlBase + '_' + j + '.html';
|
||||
|
||||
try {
|
||||
response = await axios({
|
||||
method: 'get',
|
||||
url: u,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
break;
|
||||
}
|
||||
|
||||
const page = cheerio.load(response.data, {
|
||||
decodeEntities: false,
|
||||
});
|
||||
|
||||
if (type === 'download') {
|
||||
content = page('.jieshao').html();
|
||||
} else {
|
||||
// 提取页数
|
||||
if (j === 1) {
|
||||
if (page('.pagelistbox').length === 0) {
|
||||
total = 1;
|
||||
} else {
|
||||
total = parseInt(
|
||||
page('.pagelistbox')
|
||||
.find('span')
|
||||
.html()
|
||||
.match(/共 (\S*) 页/)[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 去除不需要的元素
|
||||
page('.page_fenye').remove(); // 翻页
|
||||
page('.con p')
|
||||
.last()
|
||||
.remove(); // 专题跳转
|
||||
if (total > 1) {
|
||||
page('.con p')
|
||||
.last()
|
||||
.remove(); // 快速翻页提示
|
||||
}
|
||||
|
||||
content += page('.con div')
|
||||
.next()
|
||||
.html();
|
||||
}
|
||||
|
||||
if (j >= total) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item = {
|
||||
title: item.find('p').text(),
|
||||
description: content,
|
||||
pubDate: item.find('span').text(),
|
||||
link: url,
|
||||
guid: url,
|
||||
};
|
||||
|
||||
ctx.cache.set(url, item, 24 * 60 * 60);
|
||||
}
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title')
|
||||
.text()
|
||||
.split('_')[0],
|
||||
link: url,
|
||||
description: $('.game-pc>p').text(),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user