Support fulltext acquirement in infzm (#8590)

This commit is contained in:
Peng Guanwen
2021-11-27 17:16:08 +08:00
committed by GitHub
parent 5e889894b5
commit 0230a94673
3 changed files with 15 additions and 17 deletions

View File

@@ -707,3 +707,6 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id` - `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id`
- `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash` - `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash`
- `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk` - `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk`
- 南方周末付费全文
- `INFZM_COOKIE`: infzm 账户登陆后的 cookie目前只需要 `passport_session=...` 即可获取全文

View File

@@ -202,6 +202,9 @@ const calculateValue = () => {
ipb_pass_hash: envs.EH_IPB_PASS_HASH, ipb_pass_hash: envs.EH_IPB_PASS_HASH,
sk: envs.EH_SK, sk: envs.EH_SK,
}, },
infzm: {
cookie: envs.INFZM_COOKIE,
},
}; };
}; };
calculateValue(); calculateValue();

View File

@@ -1,3 +1,4 @@
const config = require('@/config').value;
const got = require('@/utils/got'); const got = require('@/utils/got');
const timezone = require('@/utils/timezone'); const timezone = require('@/utils/timezone');
const cheerio = require('cheerio'); const cheerio = require('cheerio');
@@ -28,26 +29,17 @@ module.exports = async (ctx) => {
if (value) { if (value) {
description = value; description = value;
} else { } else {
const cookie = config.infzm.cookie;
const response = await got({ const response = await got({
method: 'get', method: 'get',
url: `http://api.infzm.com/mobile/contents/${id}`, url: `http://www.infzm.com/content/${id}`,
headers: {
Referer: link,
Cookie: cookie || `passport_session=${Math.floor(Math.random() * 100)};`,
},
}); });
const $ = cheerio.load(response.data);
if (response.data.code === 200) { description = $('div.nfzm-content__content').html();
description = response.data.data.content.fulltext;
} else {
// 有时候接口会返回未发布但实际已发布
const response = await got({
method: 'get',
url: `http://www.infzm.com/content/${id}`,
headers: {
Referer: link,
Cookie: `PHPSESSID=${Math.floor(Math.random() * 100)};`,
},
});
const $ = cheerio.load(response.data);
description = $('#content').html();
}
ctx.cache.set(key, description); ctx.cache.set(key, description);
} }