Files
RSSHub/lib/v2/aip/journal.js
T
Derekandgithub-actions[bot] 8d4dbb9a80 fix(route): update v2/scitation to v2/aip (#12955)
* fix(route): scitation/journal

* fix(docs): scitation/journal

* fix(docs): (en) scitation/journal

* chores

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* style: auto format

* fix(route): mv scitation to aip

* fix(route): v2/AIP chores

* fix(docs): v2/aip docs

* fix(docs): chores: jounus/advanced/advanced-feed

* fix(docs): update en docs

* fix(docs): not right close the <RouteEn>

* fix(docs): correct some mistake

* Update lib/v2/aip/radar.js

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-19 20:44:11 +08:00

56 lines
1.8 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { renderDesc } = require('./utils');
module.exports = async (ctx) => {
const pub = ctx.params.pub;
const jrn = ctx.params.jrn;
const host = `https://pubs.aip.org`;
const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
const { data: response } = await got.get(jrnlUrl);
const $ = cheerio.load(response);
const jrnlName = $('meta[property="og:title"]')
.attr('content')
.match(/(?:[^=]*=)?\s*([^>]+)\s*/)[1];
const publication = $('.al-article-item-wrap.al-normal');
const list = publication
.map((_, item) => {
const title = $(item).find('.item-title a:first').text();
const link = $(item).find('.item-title a:first').attr('href');
const doilink = $(item).find('.citation-label a').attr('href');
const doi = doilink && doilink.match(/10\.\d+\/\S+/)[0];
const id = $(item).find('h5[data-resource-id-access]').data('resource-id-access');
const authors = $(item)
.find('.al-authors-list')
.find('a')
.map(function () {
return $(this).text();
})
.get()
.join('; ');
const imgUrl = $(item).find('.issue-featured-image a img').attr('src');
const img = imgUrl ? imgUrl.replace(/\?.+$/, '') : '';
const description = renderDesc(title, authors, doi, img);
return {
title,
link,
doilink,
id,
authors,
img,
doi,
description,
};
})
.get();
ctx.state.data = {
title: jrnlName,
link: jrnlUrl,
item: list,
allowEmpty: true,
};
};