diff --git a/lib/routes/gov/news/index.js b/lib/routes/gov/news/index.js index 806fd06db..48e6756db 100644 --- a/lib/routes/gov/news/index.js +++ b/lib/routes/gov/news/index.js @@ -55,37 +55,53 @@ module.exports = async (ctx) => { let fullTextGet = ''; if (item.html().search(/dysMiddleResultConItemTitle/g) !== -1) { contentUrl = item.find('a').attr('href'); - description = await ctx.cache.tryGet(contentUrl, async () => { - fullTextGet = await got.get(contentUrl); - fullTextData = cheerio.load(fullTextGet.data); - if (fullTextData.html().search(/pages_content/g) !== -1) { - return fullTextData('.pages_content').html(); - } else { - return fullTextData('#UCAP-CONTENT').html(); - } - }); + if (contentUrl.search(/content/g) === -1) { + description = item.find('a').text(); // 忽略获取吹风会的全文 + } else { + description = await ctx.cache.tryGet(contentUrl, async () => { + fullTextGet = await got.get(contentUrl); + fullTextData = cheerio.load(fullTextGet.data); + if (fullTextData.html().search(/pages_content/g) !== -1) { + fullTextData('.shuzi').remove(); // 移除videobg的图片 + fullTextData('#myFlash').remove(); // 移除flash + return fullTextData('.pages_content').html(); + } else { + fullTextData('.shuzi').remove(); // 移除videobg的图片 + fullTextData('#myFlash').remove(); // 移除flash + return fullTextData('#UCAP-CONTENT').html(); + } + }); + } } else { href = item.find('a').attr('href'); contentUrl = href.startsWith('/') ? `http://www.gov.cn${href}` : href; - description = await ctx.cache.tryGet(contentUrl, async () => { - fullTextGet = await got.get(contentUrl); - fullTextData = cheerio.load(fullTextGet.data); - const $1 = fullTextData.html(); - if (contentUrl.search(/zhengceku/g) !== -1) { - fullText = fullTextData('.pages_content').html(); - } else { - if ($1.search(/UCAP-CONTENT/g) === -1) { - fullText = fullTextData('body').html(); + if (contentUrl.search(/content/g) === -1) { + description = item.find('a').text(); // 忽略获取吹风会的全文 + } else { + description = await ctx.cache.tryGet(contentUrl, async () => { + fullTextGet = await got.get(contentUrl); + fullTextData = cheerio.load(fullTextGet.data); + const $1 = fullTextData.html(); + if (contentUrl.search(/zhengceku/g) !== -1) { + // 政策文件库 + fullText = fullTextData('.pages_content').html(); } else { - fullTextData('.shuzi').remove(); - fullText = fullTextData('#UCAP-CONTENT').html(); + if ($1.search(/UCAP-CONTENT/g) === -1) { + fullTextData('.shuzi').remove(); // 移除videobg的图片 + fullTextData('#myFlash').remove(); // 移除flash + fullText = fullTextData('body').html(); + } else { + fullTextData('.shuzi').remove(); // 移除videobg的图片 + fullTextData('#myFlash').remove(); // 移除flash + fullText = fullTextData('#UCAP-CONTENT').html(); + } } - } - const regImg = /(img src=")(.*)(".*)/g; - const regUrl = /(http.*\/)(content.*)/; - const urlSplit = contentUrl.replace(regUrl, '$1'); - return fullText.replace(regImg, '$1' + urlSplit + '$2' + '$3'); - }); + const regImg = /(img src=")(.*)(".*)/g; + const regUrl = /(http.*\/)(content.*)/; + const urlSplit = contentUrl.replace(regUrl, '$1'); + return fullText.replace(regImg, '$1' + urlSplit + '$2' + '$3'); // 处理图片链接 + }); + } } return { title: item.find('a').text(), diff --git a/lib/routes/gov/statecouncil/briefing.js b/lib/routes/gov/statecouncil/briefing.js index 73744602b..ecd5b79c8 100644 --- a/lib/routes/gov/statecouncil/briefing.js +++ b/lib/routes/gov/statecouncil/briefing.js @@ -16,14 +16,14 @@ module.exports = async (ctx) => { .map(async (index, item) => { item = $(item); const contenlUrl = item.find('a').attr('href'); - const description = await ctx.cache.tryGet(contenlUrl, async () => { - const fullText = await got.get(contenlUrl); - const fullTextData = cheerio.load(fullText.data); - return fullTextData('.online_list').html(); - }); + // const description = await ctx.cache.tryGet(contenlUrl, async () => { + // const fullText = await got.get(contenlUrl); + // const fullTextData = cheerio.load(fullText.data); + // return fullTextData('.online_list').html(); + // }); return { title: item.find('a').text(), - description: description, + description: item.find('a').text(), link: contenlUrl, }; })