mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 23:59:56 +08:00
@@ -209,6 +209,12 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa
|
||||
|
||||
<Route author="nczitzk" example="/smzdm/baoliao/7367111021" path="/smzdm/baoliao/:uid" :paramsDesc="['用户id,网址上直接可以看到']"/>
|
||||
|
||||
## 它惠网
|
||||
|
||||
### 线报
|
||||
|
||||
<Route author="nczitzk" example="/tahui/rptlist" path="/tahui/rptlist"/>
|
||||
|
||||
## 淘宝众筹
|
||||
|
||||
### 众筹项目
|
||||
|
||||
@@ -3119,6 +3119,9 @@ router.get('/fjnews/fz/30', require('./routes/fjnews/fznews'));
|
||||
// 九江新闻jjnews
|
||||
router.get('/fjnews/jjnews', require('./routes/fjnews/jjnews'));
|
||||
|
||||
// 它惠网
|
||||
router.get('/tahui/rptlist', require('./routes/tahui/rptlist'));
|
||||
|
||||
// Guiltfree
|
||||
router.get('/guiltfree/onsale', require('./routes/guiltfree/onsale'));
|
||||
|
||||
|
||||
49
lib/routes/tahui/rptlist.js
Normal file
49
lib/routes/tahui/rptlist.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.tahui.com/';
|
||||
const currentUrl = 'https://www.tahui.com/rptlist';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('article.excerpt h2')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a').eq(0);
|
||||
return {
|
||||
title: a.text(),
|
||||
link: url.resolve(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,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.pubDate = new Date(content('div.meta span').eq(0).text().trim().replace(/\n/g, '')).toUTCString();
|
||||
item.description = content('div.artcontent').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '它惠网 - 线报',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user