+24
@@ -4,6 +4,30 @@ pageClass: routes
|
||||
|
||||
# 论坛
|
||||
|
||||
## 19 楼
|
||||
|
||||
### 头条
|
||||
|
||||
<Route author="nczitzk" example="/19lou/jiaxing" path="/19lou/:city?" :paramsDesc="['分类,见下表,默认为 www,即杭州']">
|
||||
|
||||
| 杭州 | 台州 | 嘉兴 | 宁波 | 湖州 |
|
||||
| --- | ------- | ------- | ------ | ------ |
|
||||
| www | taizhou | jiaxing | ningbo | huzhou |
|
||||
|
||||
| 绍兴 | 湖州 | 温州 | 金华 | 舟山 |
|
||||
| -------- | ------ | ------- | ------ | -------- |
|
||||
| shaoxing | huzhou | wenzhou | jinhua | zhoushan |
|
||||
|
||||
| 衢州 | 丽水 | 义乌 | 萧山 | 余杭 |
|
||||
| ------ | ------ | ---- | -------- | ------ |
|
||||
| quzhou | lishui | yiwu | xiaoshan | yuhang |
|
||||
|
||||
| 临安 | 富阳 | 桐庐 | 建德 | 淳安 |
|
||||
| ----- | ------ | ------ | ------ | ------ |
|
||||
| linan | fuyang | tonglu | jiande | chunan |
|
||||
|
||||
</Route>
|
||||
|
||||
## 2047
|
||||
|
||||
### 分类
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
const setCookie = function (cookieName, cookieValue, seconds, path, domain, secure) {
|
||||
let expires = null;
|
||||
if (seconds !== -1) {
|
||||
expires = new Date();
|
||||
expires.setTime(expires.getTime() + seconds);
|
||||
}
|
||||
return [encodeURI(cookieName), '=', encodeURI(cookieValue), expires ? '; expires=' + expires.toGMTString() : '', path ? '; path=' + path : '/', domain ? '; domain=' + domain : '', secure ? '; secure' : ''].join('');
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const city = ctx.params.city ?? 'www';
|
||||
|
||||
const rootUrl = `https://${city}.19lou.com`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
|
||||
$('.title-more').remove();
|
||||
|
||||
let items = $('.center-center-jiazi')
|
||||
.find('a[title]')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: `https:${item.attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
responseType: 'buffer',
|
||||
headers: {
|
||||
cookie: setCookie('_Z3nY0d4C_', '37XgPK9h', 365, '/', '19lou.com'),
|
||||
referer: rootUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
content('.name-lz, .postView-pk-mod').remove();
|
||||
|
||||
item.author = content('.uname, .user-name').first().text();
|
||||
item.description = content('.post-cont').first().html() || content('.thread-cont').html();
|
||||
item.pubDate = timezone(parseDate(content('.cont-top-left meta').first().attr('content')), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text().split('-')[0],
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:city?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
module.exports = {
|
||||
'19lou.com': {
|
||||
_name: '19 楼',
|
||||
'.': [
|
||||
{
|
||||
title: '头条',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#19-lou-tou-tiao',
|
||||
source: ['/'],
|
||||
target: (params, url) => `/19lou/${new URL(url).toString().match(/\/\/(.*?)\.19lou/)[1]}`,
|
||||
},
|
||||
],
|
||||
www: [
|
||||
{
|
||||
title: '头条',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#19-lou-tou-tiao',
|
||||
source: ['/'],
|
||||
target: '/19lou/www',
|
||||
},
|
||||
],
|
||||
jiaxing: [
|
||||
{
|
||||
title: '头条',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#19-lou-tou-tiao',
|
||||
source: ['/'],
|
||||
target: '/19lou/jiaxing',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:city?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user