@@ -55,6 +55,12 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## 爱 Q 生活网
|
||||
|
||||
### 最近更新
|
||||
|
||||
<Route author="nczitzk" example="/iqshw/latest" path="/iqshw/latest"/>
|
||||
|
||||
## BOOKSOURCE.STORE
|
||||
|
||||
### 书源仓库更新
|
||||
|
||||
@@ -3081,6 +3081,9 @@ router.get('/souyun/today', require('./routes/souyun/today'));
|
||||
// 生物谷
|
||||
router.get('/bioon/latest', require('./routes/bioon/latest'));
|
||||
|
||||
// 爱Q生活网
|
||||
router.get('/iqshw/latest', require('./routes/iqshw/latest'));
|
||||
|
||||
// JustRun
|
||||
router.get('/justrun', require('./routes/justrun/index'));
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.iqshw.com';
|
||||
const currentUrl = `${rootUrl}/post/new_100/`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gb2312'));
|
||||
const list = $('ul.list-item li')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
|
||||
return {
|
||||
title: a.attr('title'),
|
||||
link: rootUrl + a.attr('href'),
|
||||
};
|
||||
})
|
||||
.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,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gb2312'));
|
||||
|
||||
item.pubDate = new Date(content('span.time').text() + ' GMT+8').toUTCString();
|
||||
item.description = content('div.content-intro').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '爱Q生活网 - 最近更新',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user