feat(route): add 亿欧网 (#6926)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
parent
b99f8072d4
commit
b72f8778d6
|
|
@ -1907,7 +1907,7 @@ column 为 third 时可选的 category:
|
|||
|
||||
优先使用方法一,若是网易号搜索页面搜不到的小众网易号(文章页面不含`data-wemediaid`)则可使用此法。
|
||||
触发反爬会只抓取到标题,建议自建。
|
||||
<Route author="mjysci" example="/netease/dy2/T1555591616739" path="/netease/dy2/:id" :paramsDesc="['id,该网易号主页网址最后一项html的文件名']" anticrawler="1"/>
|
||||
<Route author="mjysci" example="/netease/dy2/T1555591616739" path="/netease/dy2/:id" :paramsDesc="['id,该网易号主页网址最后一项html的文件名']" anticrawler="1"/>
|
||||
|
||||
## 网易新闻
|
||||
|
||||
|
|
@ -2297,3 +2297,9 @@ QueryString:
|
|||
### 全文
|
||||
|
||||
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
|
||||
|
||||
## 亿欧网
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="WenryXu" example="/iyiou" path="/iyiou"/>
|
||||
|
|
|
|||
|
|
@ -3964,7 +3964,11 @@ 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('/iyiou', require('./routes/iyiou'));
|
||||
|
||||
// 香港商报
|
||||
router.get('/hkcd/pdf', require('./routes/hkcd/pdf'));
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const formatPubDate = require('@/utils/date.js');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://www.iyiou.com/news`,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const postList = $('.list-container').find('.eo-article-column').get();
|
||||
const result = await Promise.all(
|
||||
postList.map(async (item) => {
|
||||
const title = $(item).find('.eo-hover-child').find('.content').find('a').find('.title').text();
|
||||
const link = 'https://www.iyiou.com' + $(item).find('.eo-hover-child').find('a').attr('href');
|
||||
const guid = link;
|
||||
const pubDate = formatPubDate($(item).find('.eo-hover-child').find('.content').find('.eo-post-date').text().replace(' ', ''));
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: link,
|
||||
guid: guid,
|
||||
pubDate: pubDate,
|
||||
description: '',
|
||||
};
|
||||
|
||||
const description_key = 'iyiou' + guid;
|
||||
const description_value = await ctx.cache.get(description_key);
|
||||
|
||||
if (description_value) {
|
||||
single.description = description_value;
|
||||
} else {
|
||||
const temp = await got(link);
|
||||
single.description = $(temp.data).find('.post-body').html();
|
||||
ctx.cache.set(description_key, single.description);
|
||||
}
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = { title: '亿欧网', link: 'https://www.iyiou.com/', item: result };
|
||||
};
|
||||
Loading…
Reference in New Issue