parent
9a3b543eec
commit
609063ffff
|
|
@ -815,6 +815,12 @@ category 对应的关键词有
|
|||
|
||||
</Route>
|
||||
|
||||
## 香港商报
|
||||
|
||||
### PDF 版
|
||||
|
||||
<Route author="nczitzk" example="/hkcd/pdf" path="/hkcd/pdf"/>
|
||||
|
||||
## 新京报
|
||||
|
||||
### 栏目
|
||||
|
|
|
|||
|
|
@ -3961,4 +3961,7 @@ router.get('/furaffinity/favorites/:username/:nsfw?', require('./routes/furaffin
|
|||
router.get('/furaffinity/submission_comments/:id', require('./routes/furaffinity/submission_comments'));
|
||||
router.get('/furaffinity/journal_comments/:id', require('./routes/furaffinity/journal_comments'));
|
||||
|
||||
// 香港商报
|
||||
router.get('/hkcd/pdf', require('./routes/hkcd/pdf'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://hk.hkcd.com';
|
||||
const currentUrl = `${rootUrl}/pdf/index.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const data = iconv.decode(response.data, 'gb2312');
|
||||
const date = data.match(/<td align="right"><font color="#FFFFFF">(.*)/)[1];
|
||||
const $ = cheerio.load(data.replace('<table width="177" border="0" cellspacing="1" cellpadding="0"', '<table id="content" width="177" border="0" cellspacing="1" cellpadding="0"'));
|
||||
|
||||
ctx.state.data = {
|
||||
title: '香港商报PDF版',
|
||||
link: currentUrl,
|
||||
item: [
|
||||
{
|
||||
title: date,
|
||||
link: currentUrl,
|
||||
description: $('#content').html(),
|
||||
pubDate: new Date(date.replace(/年|月/g, '-').replace(/日/, '')).toUTCString(),
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue