mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
@@ -2361,6 +2361,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
|||||||
|
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
### All Poetry
|
||||||
|
|
||||||
|
<route name="Poems" author="HenryQW" example="/allpoetry/newest" path="/allpoetry/:order?" :paramsDesc="['排序方式, `best` 或 `newest`, 缺省 `best`']"/>
|
||||||
|
|
||||||
## 中国驻外使领馆
|
## 中国驻外使领馆
|
||||||
|
|
||||||
### 大使馆
|
### 大使馆
|
||||||
|
|||||||
@@ -423,3 +423,7 @@ Supported sub-sites:
|
|||||||
| Mac | Google | Toys |
|
| Mac | Google | Toys |
|
||||||
|
|
||||||
</routeEn>
|
</routeEn>
|
||||||
|
|
||||||
|
### All Poetry
|
||||||
|
|
||||||
|
<routeEn name="Poems" author="HenryQW" example="/allpoetry/newest" path="/allpoetry/:order?" :paramsDesc="['order by type, `best` or `newest`, default to `best`']"/>
|
||||||
|
|||||||
@@ -964,6 +964,9 @@ router.get('/jingdong/zhongchou/:type/:status/:sort', require('./routes/jingdong
|
|||||||
// 淘宝众筹
|
// 淘宝众筹
|
||||||
router.get('/taobao/zhongchou/:type?', require('./routes/taobao/zhongchou'));
|
router.get('/taobao/zhongchou/:type?', require('./routes/taobao/zhongchou'));
|
||||||
|
|
||||||
|
// All Poetry
|
||||||
|
router.get('/allpoetry/:order?', require('./routes/allpoetry/order'));
|
||||||
|
|
||||||
// 华尔街见闻
|
// 华尔街见闻
|
||||||
router.get('/wallstreetcn/news/global', require('./routes/wallstreetcn/news'));
|
router.get('/wallstreetcn/news/global', require('./routes/wallstreetcn/news'));
|
||||||
|
|
||||||
|
|||||||
59
lib/routes/allpoetry/order.js
Normal file
59
lib/routes/allpoetry/order.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { order = 'best' } = ctx.params;
|
||||||
|
const link = `https://allpoetry.com/poems/about/spotlight-oldpoem?order=${order}}`;
|
||||||
|
const host = 'https://allpoetry.com/';
|
||||||
|
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
$('.sub')
|
||||||
|
.slice(0, 5)
|
||||||
|
.get()
|
||||||
|
.map(async (e) => {
|
||||||
|
let itemUrl = $(e)
|
||||||
|
.find('h1.title > a')
|
||||||
|
.attr('href');
|
||||||
|
|
||||||
|
itemUrl = url.resolve(host, itemUrl);
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: $(e)
|
||||||
|
.find('h1.title > a')
|
||||||
|
.text(),
|
||||||
|
description: $(e)
|
||||||
|
.find('div.poem_body')
|
||||||
|
.html(),
|
||||||
|
link: itemUrl,
|
||||||
|
author: $(e)
|
||||||
|
.find('div.bio >a ')
|
||||||
|
.attr('data-name'),
|
||||||
|
guid: itemUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `All Poetry - ${order.toUpperCase() + order.slice(1)}`,
|
||||||
|
link,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user