mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
29 lines
857 B
JavaScript
29 lines
857 B
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const currentUrl = `http://export.arxiv.org/api/query?${ctx.params.query}`;
|
|
const response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('entry')
|
|
.map((_, item) => {
|
|
item = $(item);
|
|
return {
|
|
title: item.find('title').text(),
|
|
link: item.find('link[type="text/html"]').attr('href'),
|
|
pubDate: new Date(item.find('published').text()).toUTCString(),
|
|
description: item.find('summary').text(),
|
|
};
|
|
})
|
|
.get();
|
|
|
|
ctx.state.data = {
|
|
title: 'arXiv (' + ctx.params.query + ')',
|
|
link: currentUrl,
|
|
item: list,
|
|
};
|
|
};
|