Add(route): add informs (#8873)
This commit is contained in:
parent
b9bcf4fdac
commit
b373c249df
|
|
@ -124,6 +124,10 @@ New items may always at the end of the list, when the number of paper entries is
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## INFORMS
|
||||
|
||||
<RouteEn author="Fatpandac" example="/informs/mnsc" path="/informs/:category?" :paramsDesc="['Category, can be found in the url of the page, `orsc` by default']"/>
|
||||
|
||||
## JASA
|
||||
|
||||
### Latest Research
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ Language
|
|||
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||
| en | ar | zh | fr | ru | es | pt |
|
||||
|
||||
</Route>
|
||||
</RouteEn>
|
||||
|
||||
### Newsroom
|
||||
|
||||
|
|
@ -642,4 +642,4 @@ Language
|
|||
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||
| en | ar | zh | fr | ru | es | pt |
|
||||
|
||||
</Route>
|
||||
</RouteEn>
|
||||
|
|
|
|||
|
|
@ -120,6 +120,10 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## INFORMS
|
||||
|
||||
<Route author="Fatpandac" example="/informs/mnsc" path="/informs/:category?" :paramsDesc="['类型, 可以在 url 中得到,默认为 `orsc`']"/>
|
||||
|
||||
## JASA
|
||||
|
||||
### 最新文章
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
const config = require('@/config').value;
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://pubsonline.informs.org';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'orsc';
|
||||
const cateUrl = `${rootUrl}/toc/${category}/0/0`;
|
||||
|
||||
const getCookie = () =>
|
||||
ctx.cache.tryGet(cateUrl, async () => {
|
||||
const setCookiesUrl = `${cateUrl}?cookieSet=1`;
|
||||
|
||||
const response = await got.extend({ followRedirect: false }).get(setCookiesUrl, {
|
||||
headers: {
|
||||
Referer: cateUrl,
|
||||
},
|
||||
});
|
||||
const cookie = response.headers['set-cookie']
|
||||
.slice(1)
|
||||
.map((item) => item.split(';')[0])
|
||||
.join('; ');
|
||||
|
||||
return cookie;
|
||||
});
|
||||
|
||||
const response = await got.get(cateUrl, {
|
||||
headers: {
|
||||
referer: cateUrl,
|
||||
'User-Agent': config.ua,
|
||||
cookie: await getCookie(),
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.issue-item')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => ({
|
||||
title: $(item).find('h5.issue-item__title').text(),
|
||||
link: `${rootUrl}${$(item).find('h5.issue-item__title > a').attr('href')}`,
|
||||
pubDate: parseDate($(item).find('div.rlist--inline.separator.toc-item__detail > p').remove('span').text()),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got.get(item.link, {
|
||||
headers: {
|
||||
referer: cateUrl,
|
||||
'User-Agent': config.ua,
|
||||
cookie: await getCookie(),
|
||||
},
|
||||
});
|
||||
const detail = cheerio.load(detailResponse.data);
|
||||
item.description = art(path.join(__dirname, 'templates/content.art'), {
|
||||
author: detail('div.accordion-tabbed.loa-accordion').text(),
|
||||
content: detail('div.hlFld-Abstract').find('h2').replaceWith($('<h2>Abstract </h2>')).end().html(),
|
||||
});
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `INFORMS - ${category}`,
|
||||
link: cateUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:category?': ['Fatpandac'],
|
||||
};
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
module.exports = {
|
||||
'informs.org': {
|
||||
_name: 'INFORMS',
|
||||
pubsonline: [
|
||||
{
|
||||
title: 'Decision Analysis',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/deca', '/toc/deca/0/0'],
|
||||
target: `/informs/deca`,
|
||||
},
|
||||
{
|
||||
title: 'Marketing Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/mksc', '/toc/mksc/0/0'],
|
||||
target: `/informs/mksc`,
|
||||
},
|
||||
{
|
||||
title: 'Information Systems Research',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/isrc', '/toc/isrc/0/0'],
|
||||
target: `/informs/isrc`,
|
||||
},
|
||||
{
|
||||
title: 'Mathematics of Operations Research',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/moor', '/toc/moor/0/0'],
|
||||
target: `/informs/moor`,
|
||||
},
|
||||
{
|
||||
title: 'INFORMS Journal on Applied Analytics',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/inte', '/toc/inte/0/0'],
|
||||
target: `/informs/inte`,
|
||||
},
|
||||
{
|
||||
title: 'Operations Research',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/opre', '/toc/opre/0/0'],
|
||||
target: `/informs/opre`,
|
||||
},
|
||||
{
|
||||
title: 'INFORMS Journal on Computing',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/ijoc', '/toc/ijoc/0/0'],
|
||||
target: `/informs/ijoc`,
|
||||
},
|
||||
{
|
||||
title: 'Organization Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/orsc', '/toc/orsc/0/0'],
|
||||
target: `/informs/orsc`,
|
||||
},
|
||||
{
|
||||
title: 'INFORMS Journal on Data Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/ijds', '/toc/ijds/0/0'],
|
||||
target: `/informs/ijds`,
|
||||
},
|
||||
{
|
||||
title: 'Service Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/serv', '/toc/serv/0/0'],
|
||||
target: `/informs/serv`,
|
||||
},
|
||||
{
|
||||
title: 'INFORMS Journal on Optimization',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/ijoo', '/toc/ijoo/0/0'],
|
||||
target: `/informs/ijoo`,
|
||||
},
|
||||
{
|
||||
title: 'Stochastic Systems',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/stsy', '/toc/stsy/0/0'],
|
||||
target: `/informs/stsy`,
|
||||
},
|
||||
{
|
||||
title: 'INFORMS Transactions on Education',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/ited', '/toc/ited/0/0'],
|
||||
target: `/informs/ited`,
|
||||
},
|
||||
{
|
||||
title: 'Strategy Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/stsc', '/toc/stsc/0/0'],
|
||||
target: `/informs/stsc`,
|
||||
},
|
||||
{
|
||||
title: 'Management Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/mnsc', '/toc/mnsc/0/0'],
|
||||
target: `/informs/mnsc`,
|
||||
},
|
||||
{
|
||||
title: 'Transportation Science',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/trsc', '/toc/trsc/0/0'],
|
||||
target: `/informs/trsc`,
|
||||
},
|
||||
{
|
||||
title: 'Manufacturing & Service Operations Management',
|
||||
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
|
||||
source: ['/journal/msom', '/toc/msom/0/0'],
|
||||
target: `/informs/msom`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<strong> {{ author }} </strong>
|
||||
<br>
|
||||
{{ content }}
|
||||
Loading…
Reference in New Issue