Files
RSSHub/lib/v2/zhihu/weekly.js
T
08602c778c fix(route): 修复/zhihu/question无法获取,需要设置非登录状态下cookie (#9729)
* 修复/zhihu/question,需要设置非登录状态下cookie

* Update lib/routes/zhihu/execlib/g_encrypt.js

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

* 根据TonyRL review建议进行了修改

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* 增加cookie中dc_0字段检验

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* Update lib/routes/zhihu/question.js

Co-authored-by: Rongrong <Rongronggg9@outlook.com>

* refactor: migrate to v2

* fix: Incomplete URL substring sanitization

Co-authored-by: Rongrong <Rongronggg9@outlook.com>
2022-05-14 00:21:11 +08:00

32 lines
994 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const host = 'https://www.zhihu.com';
module.exports = async (ctx) => {
const link = 'https://www.zhihu.com/pub/weekly';
const response = await got(link);
const $ = cheerio.load(response.data);
const description = $('p.Weekly-description').text();
const out = $('div.Card-section.PubBookListItem')
.slice(0, 10)
.map(function () {
const info = {
title: $(this).find('span.PubBookListItem-title').text(),
link: new URL($(this).find('a.PubBookListItem-buttonWrapper').attr('href'), host).href,
description: $(this).find('div.PubBookListItem-description').text(),
author: $(this).find('span.PubBookListItem-author').text(),
};
return info;
})
.get();
ctx.state.data = {
title: '知乎周刊',
link,
description,
item: out,
};
};