parent
4dfcd8cdeb
commit
46d8d6a7dd
|
|
@ -483,6 +483,18 @@ Supported sub-sites:
|
|||
|
||||
<Route author="1813927768" example="/baidu/daily" path="/baidu/daily"/>
|
||||
|
||||
## 八阕
|
||||
|
||||
### 广角新闻
|
||||
|
||||
<Route author="nczitzk" example="/popyard" path="/popyard/:caty?" :paramsDesc="['分类, 默认为全景']">
|
||||
|
||||
| 全景 | 中国 | 国际 | 科教 | 军事 | 体育 | 娱乐 | 艺术 | 文史 | 观点 | 生活 | 产经 | 其它 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 白鲸出海
|
||||
|
||||
### 首页最新帖子
|
||||
|
|
|
|||
|
|
@ -3332,6 +3332,9 @@ router.get('/npc/:caty', require('./routes/npc/index'));
|
|||
// 高科技行业门户
|
||||
router.get('/ofweek/news', require('./routes/ofweek/news'));
|
||||
|
||||
// 八阕
|
||||
router.get('/popyard/:caty?', require('./routes/popyard/index'));
|
||||
|
||||
// 原神
|
||||
router.get('/yuanshen/:location?/:category?', require('./routes/yuanshen/index'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.caty = ctx.params.caty || '0';
|
||||
|
||||
const rootUrl = 'https://www.popyard.com';
|
||||
const currentUrl = `${rootUrl}/cgi-mod/threads.cgi?cate=${ctx.params.caty}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('li a')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}/cgi-mod${item.attr('href').replace('.', '')}`,
|
||||
author: item.next().text().split('[')[0],
|
||||
pubDate: new Date(
|
||||
item
|
||||
.next()
|
||||
.text()
|
||||
.match(/\[(.*)\]/)[1] + 'GMT+8'
|
||||
).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
headers: {
|
||||
Referer: currentUrl,
|
||||
},
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const description = content('#sponser').parent();
|
||||
|
||||
const pages = description.parents('p').eq(0).next('p').find('font a');
|
||||
|
||||
const subPages = [],
|
||||
pageLinks = [];
|
||||
|
||||
pages.each(function () {
|
||||
pageLinks.push(`${rootUrl}/cgi-mod${content(this).attr('href').replace('.', '')}`);
|
||||
});
|
||||
|
||||
if (pages.length > 0) {
|
||||
pageLinks.forEach(
|
||||
async (link) =>
|
||||
await ctx.cache.tryGet(link, async () => {
|
||||
const pageResponse = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
headers: {
|
||||
Referer: currentUrl,
|
||||
},
|
||||
});
|
||||
const subContent = cheerio.load(pageResponse.data);
|
||||
|
||||
const subDescription = subContent('#sponser').parent();
|
||||
|
||||
subContent('#sponser').prev('table').remove();
|
||||
subContent('#sponser').remove();
|
||||
|
||||
subPages.push(subDescription.html());
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
content('#sponser').prev('table').remove();
|
||||
content('#sponser').remove();
|
||||
|
||||
item.description = description.html() + subPages.join('');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue