fix: 微信公众号二十次幂来源 (#5908)
This commit is contained in:
+1
-1
@@ -1385,7 +1385,7 @@ area 分区选项
|
||||
|
||||
### 公众号 (二十次幂来源)
|
||||
|
||||
<Route author="sanmmm" example="/wechat/ershicimi/59" path="/wechat/ershicimi/:id" :paramsDesc="['公众号id, 打开公众号页, 在 URL 中找到 id']"/>
|
||||
<Route author="sanmmm" example="/wechat/ershicimi/813oxJOl" path="/wechat/ershicimi/:id" :paramsDesc="['公众号id, 打开公众号页, 在 URL 中找到 id']"/>
|
||||
|
||||
### 公众号 (外接大脑来源)
|
||||
|
||||
|
||||
@@ -6,16 +6,35 @@ module.exports = async (ctx) => {
|
||||
const url = `https://www.ershicimi.com/a/${id}`;
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const items = $('.weui_media_box')
|
||||
const list = $('.weui_media_box')
|
||||
.map((_, ele) => {
|
||||
const $item = cheerio.load(ele);
|
||||
return {
|
||||
title: $item('.weui_media_title a').text(),
|
||||
link: $item('.weui_media_title a').attr('href'),
|
||||
description: $item('.weui_media_desc').text(),
|
||||
link: `https://www.ershicimi.com${$item('.weui_media_title a').attr('href')}`,
|
||||
pubDate: new Date($item('.weui_media_extra_info').attr('title')).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailRepsonse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailRepsonse.data);
|
||||
|
||||
item.description = content('.article-content').html() ? content('.article-content').html() : item.description;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `微信公众号 - ${$('span.name').text()}`,
|
||||
link: url,
|
||||
|
||||
Reference in New Issue
Block a user