mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): tencent author (#14241)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const config = require('@/config').value;
|
||||
const { art } = require('@/utils/render');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const mid = ctx.params.mid;
|
||||
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
|
||||
const items = await Promise.all(
|
||||
news.map((item) => {
|
||||
const title = item.title;
|
||||
const pubDate = timezone(parseDate(item.time), +8);
|
||||
const pubDate = parseDate(item.timestamp, 'X');
|
||||
const itemUrl = item.url;
|
||||
const author = item.source;
|
||||
const abstract = item.abstract;
|
||||
@@ -26,11 +27,26 @@ module.exports = async (ctx) => {
|
||||
return ctx.cache.tryGet(itemUrl, async () => {
|
||||
const response = await got(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const article = $('#ArticleContent');
|
||||
const data = JSON.parse(
|
||||
$('script:contains("window.DATA")')
|
||||
.text()
|
||||
.match(/window\.DATA = (\{.+\});/)[1]
|
||||
);
|
||||
const $data = cheerio.load(data.originContent.text, null, false);
|
||||
|
||||
$data('*')
|
||||
.contents()
|
||||
.filter((_, elem) => elem.type === 'comment')
|
||||
.replaceWith((_, elem) =>
|
||||
art(join(__dirname, '../templates/news/image.art'), {
|
||||
attribute: elem.data.trim(),
|
||||
originAttribute: data.originAttribute,
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
title,
|
||||
description: article.html() || abstract,
|
||||
description: $data.html() || abstract,
|
||||
link: itemUrl,
|
||||
author,
|
||||
pubDate,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{{ if attribute?.startsWith('IMG') && originAttribute[attribute] }}
|
||||
{{ set image = originAttribute[attribute] }}
|
||||
<img src="{{ image.bigOrigUrl }}" style="{{ image.style }}" >
|
||||
{{ /if }}
|
||||
Reference in New Issue
Block a user