fix(route)(twreporter): title,author,pubDate (#9502)
* fix(route): twreporter title,author,pubDate * refactor: migrate to v2 * fix: missing maintainer
This commit is contained in:
parent
928b089cc8
commit
69210f7cad
|
|
@ -42,10 +42,10 @@ router.get('/bangumi/group/:id', lazyloadRouteHandler('./routes/bangumi/group/to
|
|||
router.get('/bangumi/subject/:id', lazyloadRouteHandler('./routes/bangumi/subject'));
|
||||
router.get('/bangumi/user/blog/:id', lazyloadRouteHandler('./routes/bangumi/user/blog'));
|
||||
|
||||
// 報導者
|
||||
router.get('/twreporter/newest', lazyloadRouteHandler('./routes/twreporter/newest'));
|
||||
router.get('/twreporter/photography', lazyloadRouteHandler('./routes/twreporter/photography'));
|
||||
router.get('/twreporter/category/:cid', lazyloadRouteHandler('./routes/twreporter/category'));
|
||||
// 報導者 migrated to v2
|
||||
// router.get('/twreporter/newest', lazyloadRouteHandler('./routes/twreporter/newest'));
|
||||
// router.get('/twreporter/photography', lazyloadRouteHandler('./routes/twreporter/photography'));
|
||||
// router.get('/twreporter/category/:cid', lazyloadRouteHandler('./routes/twreporter/category'));
|
||||
|
||||
// 微博
|
||||
router.get('/weibo/user/:uid/:routeParams?', lazyloadRouteHandler('./routes/weibo/user'));
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
const fetch = require('./fetch_article');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseURL = 'https://www.twreporter.org';
|
||||
const url = baseURL + `/photography`;
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const coverList = $('.WPJvn').get();
|
||||
const commonList = $('.eVNsZf').get();
|
||||
|
||||
const coverView = await Promise.all(
|
||||
coverList.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = baseURL + $('li > a').attr('href');
|
||||
const title = $('.gRCDdm').text();
|
||||
|
||||
const cache = await ctx.cache.get(address);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
|
||||
ctx.cache.set(address, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
const listView = await Promise.all(
|
||||
commonList.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = baseURL + $('li > a').attr('href');
|
||||
const title = $('.etJLWI').text();
|
||||
|
||||
const cache = await ctx.cache.get(address);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
|
||||
ctx.cache.set(address, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `報導者 | 影像`,
|
||||
link: url,
|
||||
item: coverView.concat(listView),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/blog': ['chazeon'],
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/': ['chazeon'],
|
||||
};
|
||||
|
|
@ -6,26 +6,21 @@ const fetch = require('./fetch_article');
|
|||
module.exports = async (ctx) => {
|
||||
const baseURL = 'https://www.twreporter.org';
|
||||
const url = baseURL + `/categories/${ctx.params.cid}`;
|
||||
const res = await got.get(url);
|
||||
const res = await got(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const list = $('.lnKPLr').get();
|
||||
const category = $('.kCfkTU').text();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
list.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = baseURL + $('a').attr('href');
|
||||
const title = $('.list-item__Title-sc-1dx5lew-5').text();
|
||||
const cache = await ctx.cache.get(address);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
|
||||
ctx.cache.set(address, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
return ctx.cache.tryGet(address, async () => {
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async function fetch(address) {
|
||||
const res = await got.get(address);
|
||||
const res = await got(address);
|
||||
const capture = cheerio.load(res.data);
|
||||
capture('.gIMvvS').remove();
|
||||
|
||||
let metaInfoBox = capture('.iRdvCH')
|
||||
let metaInfoBox = capture('.ffAPnj')
|
||||
.filter((index) => index === 0)
|
||||
.get();
|
||||
|
||||
// For photography
|
||||
if (metaInfoBox.length === 0) {
|
||||
metaInfoBox = capture('.dPQBaW')
|
||||
metaInfoBox = capture('.deNvJY')
|
||||
.filter((index) => index === 0)
|
||||
.get();
|
||||
}
|
||||
|
|
@ -61,6 +62,6 @@ module.exports = async function fetch(address) {
|
|||
description: contents,
|
||||
link: address,
|
||||
guid: address,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
pubDate: parseDate(time, 'M/D/YYYY'),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
'/category/:cid': ['emdoe'],
|
||||
'/newest': ['emdoe'],
|
||||
'/photography': ['emdoe'],
|
||||
};
|
||||
|
|
@ -5,25 +5,20 @@ const fetch = require('./fetch_article');
|
|||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://www.twreporter.org';
|
||||
const res = await got.get(url);
|
||||
const res = await got(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const list = $('.gKMjSz').get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
list.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = url + $('a').attr('href');
|
||||
const title = $('.dpNivU').text();
|
||||
const cache = await ctx.cache.get(address);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
|
||||
ctx.cache.set(address, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
const title = $('.latest-section__Title-hzxpx3-6').text();
|
||||
return ctx.cache.tryGet(address, async () => {
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
const fetch = require('./fetch_article');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseURL = 'https://www.twreporter.org';
|
||||
const url = baseURL + `/photography`;
|
||||
const res = await got(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
const coverList = $('.WPJvn').get();
|
||||
const commonList = $('.eVNsZf').get();
|
||||
|
||||
const coverView = await Promise.all(
|
||||
coverList.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = baseURL + $('li > a').attr('href');
|
||||
const title = $('.sc-1aojo4z-4').text();
|
||||
return ctx.cache.tryGet(address, async () => {
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const listView = await Promise.all(
|
||||
commonList.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = baseURL + $('li > a').attr('href');
|
||||
const title = $('.ii0887-4').text();
|
||||
|
||||
return ctx.cache.tryGet(address, async () => {
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `報導者 | 影像`,
|
||||
link: url,
|
||||
item: coverView.concat(listView),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
module.exports = {
|
||||
'twreporter.org': {
|
||||
_name: '報導者',
|
||||
'.': [
|
||||
{
|
||||
title: '最新',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#bao-dao-zhe',
|
||||
source: ['/'],
|
||||
target: '/twreporter/newest',
|
||||
},
|
||||
{
|
||||
title: '摄影',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#bao-dao-zhe',
|
||||
source: ['/photography'],
|
||||
target: '/twreporter',
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#bao-dao-zhe',
|
||||
source: ['/categories/:tid'],
|
||||
target: '/twreporter/category/:tid',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/category/:cid', require('./category'));
|
||||
router.get('/newest', require('./newest'));
|
||||
router.get('/photography', require('./photography'));
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
'/favorite/:id': ['imlonghao'],
|
||||
'/fund/:id': ['HenryQW', 'NathanDai'],
|
||||
'/hots': ['hillerliao'],
|
||||
'/snb/:id': ['ZhishanZhang'],
|
||||
'/stock_comments/:id/:titleLength?': ['zytomorrow'],
|
||||
'/stock_info/:id/:type?': ['YuYang'],
|
||||
'/user/:id/:type?': ['imlonghao'],
|
||||
'/user_stock/:id': ['hillerliao'],
|
||||
};
|
||||
Loading…
Reference in New Issue