fix(route): wsj (#7795)

* Fix wsj missing contents

* Update lib/routes/wsj/index.js

* Update lib/routes/wsj/index.js

* fix merging errors

* update matching rules

* refactor: migrate to v2

Duplicated issue: Close #8298

Co-authored-by: oppilate <oppilate@tutanota.com>
Co-authored-by: NeverBehave <gayhub@never.pet>
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
oppilate 2022-02-22 15:08:04 +00:00 committed by GitHub
parent 7dd591ca82
commit 47bbbedf7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 6 deletions

View File

@ -3445,8 +3445,8 @@ router.get('/liquipedia/dota2/matches/:id', lazyloadRouteHandler('./routes/liqui
// 哈尔滨市科技局
router.get('/gov/harbin/kjj', lazyloadRouteHandler('./routes/gov/harbin/kjj'));
// WSJ
router.get('/wsj/:lang/:category?', lazyloadRouteHandler('./routes/wsj/index'));
// WSJ migrated to v2
// router.get('/wsj/:lang/:category?', lazyloadRouteHandler('./routes/wsj/index'));
// China File
router.get('/chinafile/:category?', lazyloadRouteHandler('./routes/chinafile/index'));

View File

@ -1,6 +1,7 @@
const parser = require('@/utils/rss-parser');
const cheerio = require('cheerio');
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const categoryToXMLFileName = {
opinion: 'RSSOpinion.xml',
@ -57,7 +58,7 @@ module.exports = async (ctx) => {
});
const html = response.body;
const $ = cheerio.load(html);
const content = $('.articleBody > div[amp-access="access"]');
const content = $('.articleBody > section');
// Cover
const cover = $('.articleLead > div.is-lead-inset > div.header > .img-header > div.image-container > amp-img > img');
@ -73,6 +74,7 @@ module.exports = async (ctx) => {
// Metadata (categories & updatedAt)
const updatedAt = $('meta[itemprop="dateModified"]').attr('content');
const publishedAt = $('meta[itemprop="datePublished"]').attr('content');
const author = $('.author > a[rel="author"]').html();
const categories = $('meta[name="keywords"]')
.attr('content')
@ -113,9 +115,9 @@ module.exports = async (ctx) => {
return {
title: item.title,
id: item.guid,
pubDate: new Date(publishedAt).toUTCString(),
updated: new Date(updatedAt).toUTCString(),
author: item.creator,
pubDate: parseDate(publishedAt),
updated: parseDate(updatedAt),
author,
link: item.link,
summary,
description: content.html(),

3
lib/v2/wsj/maintainer.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/:lang/:category?': ['oppilate'],
};

21
lib/v2/wsj/radar.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
'wsj.com': {
_name: '华尔街日报 The Wall Street Journal (WSJ)',
cn: [
{
title: '新闻',
docs: 'https://docs.rsshub.app/traditional-media.html#hua-er-jie-ri-bao-the-wall-street-journal-wsj',
souce: '/',
target: '/wsj/zh-cn',
},
],
www: [
{
title: '新闻',
docs: 'https://docs.rsshub.app/traditional-media.html#hua-er-jie-ri-bao-the-wall-street-journal-wsj',
souce: '/',
target: '/wsj/en-us',
},
],
},
};

3
lib/v2/wsj/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:lang/:category?', require('./index'));
};