Files
RSSHub/lib/v2/douban/other/latest_book.js
T
FatpandacandTony 8891ad1020 feat(route): add 豆瓣招聘 and refactor to V2 standard (#8937)
* Add(route): add 豆瓣招聘 and change to V2

* Fix(route): fix typo of filename

* Fix(route): sort routes

* Fix(route): Update lib/v2/douban/router.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2022-02-02 22:56:13 +08:00

20 lines
627 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = 'https://book.douban.com/latest';
module.exports = async (ctx) => {
const res = await got.get(url);
const $ = cheerio.load(res.data);
const list = $('#content').find('li').get();
ctx.state.data = {
title: '豆瓣新书速递',
link: url,
item: list.map((item, index) => ({
title: `${index < 20 ? '[虚构类]' : '[非虚构类]'}${$(item).find('h2').text().trim()}`,
link: $(item).find('a').first().attr('href'),
description: $(item).html(),
})),
};
};