feat: 解决中国政府网部分新闻的全文样式错误问题,更改吹风会地址 (#2780)
This commit is contained in:
@@ -44,13 +44,11 @@ module.exports = async (ctx) => {
|
||||
const description = await ctx.cache.tryGet(contenlUrl, async () => {
|
||||
const fullTextGet = await got.get(contenlUrl);
|
||||
const fullTextData = cheerio.load(fullTextGet.data);
|
||||
if (uid === 'yaowen') {
|
||||
const $1 = fullTextData.html();
|
||||
if ($1.search(/UCAP-CONTENT/g) === -1) {
|
||||
fullText = fullTextData('body').html();
|
||||
} else {
|
||||
fullText = fullTextData('.pages_content').html();
|
||||
if (fullText === null) {
|
||||
fullText = fullTextData('body').html(); // 解决国务院信息部分条目无法获取全文
|
||||
}
|
||||
fullText = fullTextData('#UCAP-CONTENT').html();
|
||||
}
|
||||
const regImg = /(img src=")(.*)(".*)/g;
|
||||
const regUrl = /(http.*\/)(content.*)/;
|
||||
@@ -60,7 +58,7 @@ module.exports = async (ctx) => {
|
||||
return {
|
||||
title: item.find('a').text(),
|
||||
description: description,
|
||||
link: item.find('a').attr('href'),
|
||||
link: contenlUrl,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
|
||||
@@ -2,10 +2,10 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `http://www.scio.gov.cn/32344/index.htm`;
|
||||
const link = `http://www.gov.cn/xinwen/xwfb_wszb.htm`;
|
||||
const listData = await got.get(link);
|
||||
const $ = cheerio.load(listData.data);
|
||||
const list = $('.list .mb10 .mt10 li');
|
||||
const list = $('.list01 li');
|
||||
|
||||
ctx.state.data = {
|
||||
title: '国务院 - 吹风会',
|
||||
@@ -20,12 +20,12 @@ module.exports = async (ctx) => {
|
||||
const description = await ctx.cache.tryGet(contenlUrl, async () => {
|
||||
const fullText = await got.get(contenlUrl);
|
||||
const fullTextData = cheerio.load(fullText.data);
|
||||
return fullTextData('.textlive');
|
||||
return fullTextData('.online_list').html();
|
||||
});
|
||||
return {
|
||||
title: item.find('a').text(),
|
||||
description: description,
|
||||
link: item.find('a').attr('href'),
|
||||
link: contenlUrl,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
|
||||
Reference in New Issue
Block a user