mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
* chore(deps): bump dayjs from 1.11.4 to 1.11.5 (#258) Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.4 to 1.11.5. - [Release notes](https://github.com/iamkun/dayjs/releases) - [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.5/CHANGELOG.md) - [Commits](https://github.com/iamkun/dayjs/compare/v1.11.4...v1.11.5) --- updated-dependencies: - dependency-name: dayjs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump rand-user-agent from 1.0.76 to 1.0.77 (#259) Bumps [rand-user-agent](https://github.com/WebScrapingAPI/rand-user-agent) from 1.0.76 to 1.0.77. - [Release notes](https://github.com/WebScrapingAPI/rand-user-agent/releases) - [Commits](https://github.com/WebScrapingAPI/rand-user-agent/commits) --- updated-dependencies: - dependency-name: rand-user-agent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump twitter-api-v2 from 1.12.3 to 1.12.5 (#261) Bumps [twitter-api-v2](https://github.com/plhery/node-twitter-api-v2) from 1.12.3 to 1.12.5. - [Release notes](https://github.com/plhery/node-twitter-api-v2/releases) - [Changelog](https://github.com/PLhery/node-twitter-api-v2/blob/master/changelog.md) - [Commits](https://github.com/plhery/node-twitter-api-v2/compare/1.12.3...1.12.5) --- updated-dependencies: - dependency-name: twitter-api-v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump puppeteer from 16.1.0 to 16.1.1 (#262) Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 16.1.0 to 16.1.1. - [Release notes](https://github.com/puppeteer/puppeteer/releases) - [Changelog](https://github.com/puppeteer/puppeteer/blob/main/CHANGELOG.md) - [Commits](https://github.com/puppeteer/puppeteer/compare/v16.1.0...v16.1.1) --- updated-dependencies: - dependency-name: puppeteer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump rand-user-agent from 1.0.77 to 1.0.78 (#268) Bumps [rand-user-agent](https://github.com/WebScrapingAPI/rand-user-agent) from 1.0.77 to 1.0.78. - [Release notes](https://github.com/WebScrapingAPI/rand-user-agent/releases) - [Commits](https://github.com/WebScrapingAPI/rand-user-agent/commits) --- updated-dependencies: - dependency-name: rand-user-agent dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump ioredis from 5.2.2 to 5.2.3 (#271) Bumps [ioredis](https://github.com/luin/ioredis) from 5.2.2 to 5.2.3. - [Release notes](https://github.com/luin/ioredis/releases) - [Changelog](https://github.com/luin/ioredis/blob/main/CHANGELOG.md) - [Commits](https://github.com/luin/ioredis/compare/v5.2.2...v5.2.3) --- updated-dependencies: - dependency-name: ioredis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(route): add 厦门网数字媒体 Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
86 lines
2.3 KiB
JavaScript
86 lines
2.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const timezone = require('@/utils/timezone');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id ?? 'xmrb';
|
|
|
|
const rootUrl = 'https://epaper.xmnn.cn';
|
|
let currentUrl = `${rootUrl}/${id === 'hxcb' ? '/hxcb/epaper/paperindex.htm' : `${id}/`}`;
|
|
|
|
let response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
let $ = cheerio.load(response.data);
|
|
|
|
const title = id === 'hxcb' ? '海西晨报电子版_厦门网' : $('title').text();
|
|
|
|
let matches = response.data.match(/window\.location\.href = "(.*?)";/);
|
|
|
|
if (!matches) {
|
|
matches = response.data.match(/setTimeout\("javascript:location\.href='(.*?)'", 3000\);/);
|
|
|
|
if (!matches) {
|
|
matches = response.data.match(/<meta http-equiv="refresh".*?content=".*?URL=(.*?)">/i);
|
|
}
|
|
}
|
|
|
|
currentUrl = new URL(matches[1], currentUrl).href;
|
|
|
|
response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
$ = cheerio.load(response.data);
|
|
|
|
$('#pdfsrc').remove();
|
|
$('.bigImg, .smallImg').remove();
|
|
|
|
$('a img').each(function () {
|
|
$(this).parent().remove();
|
|
});
|
|
|
|
let items = $('.br1, .br2, .titss')
|
|
.find('a')
|
|
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 80)
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
|
|
return {
|
|
title: item.text(),
|
|
link: new URL(item.attr('href'), currentUrl).href,
|
|
};
|
|
});
|
|
|
|
items = await Promise.all(
|
|
items.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const detailResponse = await got({
|
|
method: 'get',
|
|
url: item.link,
|
|
});
|
|
|
|
const content = cheerio.load(detailResponse.data);
|
|
|
|
content('#qw').remove();
|
|
|
|
item.description = content('.cont-b, content').html();
|
|
item.pubDate = timezone(parseDate(content('.time').text() || content('.today').text().split()[0], ['YYYY-MM-DD HH:mm', 'YYYY年MM月DD日']), +8);
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title,
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|