mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
fix(route/springer/journal): Update selectors in the web scraping code (#16278)
This commit is contained in:
@@ -30,35 +30,34 @@ export const route: Route = {
|
||||
},
|
||||
],
|
||||
name: 'Journal',
|
||||
maintainers: ['Derekmini', 'TonyRL'],
|
||||
maintainers: ['Derekmini', 'TonyRL', 'xiahaoyun'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const host = 'https://www.springer.com';
|
||||
const host = 'https://link.springer.com';
|
||||
const journal = ctx.req.param('journal');
|
||||
const jrnlUrl = `${host}/journal/${journal}`;
|
||||
const jrnlUrl = `${host}/journal/${journal}/volumes-and-issues`;
|
||||
|
||||
const response = await got(jrnlUrl, {
|
||||
cookieJar,
|
||||
});
|
||||
const $ = load(response.data);
|
||||
const jrnlName = $('h1#journalTitle').text().trim();
|
||||
const issueUrl = $('p.c-card__title.u-mb-16.u-flex-grow').find('a').attr('href');
|
||||
const jrnlName = $('span.app-journal-masthead__title').text().trim();
|
||||
const issueUrl = `${host}${$('li.c-list-group__item:first-of-type').find('a').attr('href')}`;
|
||||
|
||||
const response2 = await got(issueUrl, {
|
||||
cookieJar,
|
||||
});
|
||||
const $2 = load(response2.data);
|
||||
const issue = $2('.app-volumes-and-issues__info').find('h1').text();
|
||||
const list = $2('article.c-card')
|
||||
const issue = $2('h2.app-journal-latest-issue__heading').text();
|
||||
const list = $2('ol.u-list-reset > li')
|
||||
.map((_, item) => {
|
||||
const title = $(item).find('.c-card__title').text().trim();
|
||||
const link = $(item).find('a').attr('href');
|
||||
const title = $(item).find('h3.app-card-open__heading').find('a').text().trim();
|
||||
const link = $(item).find('h3.app-card-open__heading').find('a').attr('href');
|
||||
const doi = link.replace('https://link.springer.com/article/', '');
|
||||
const img = $(item).find('img').attr('src');
|
||||
const authors = $(item)
|
||||
.find('.c-author-list')
|
||||
.find('li')
|
||||
.map((_, item) => $(item).text().trim())
|
||||
.get()
|
||||
@@ -85,8 +84,7 @@ async function handler(ctx) {
|
||||
cookieJar,
|
||||
});
|
||||
const $3 = load(response3.data);
|
||||
$3('.c-article__sub-heading').remove();
|
||||
item.abstract = $3('div#Abs1-content').text();
|
||||
item.abstract = $3('div#Abs1-content > p:first-of-type').text();
|
||||
item.description = renderDesc(item);
|
||||
return item;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user