diff --git a/docs/install/README.md b/docs/install/README.md index b2a2f1cc4d..93e26e2cb0 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -707,3 +707,6 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 - `EH_IPB_MEMBER_ID`: E-Hentai 账户登录后 cookie 的 `ipb_member_id` 值 - `EH_IPB_PASS_HASH`: E-Hentai 账户登录后 cookie 的 `ipb_pass_hash` 值 - `EH_SK`: E-Hentai 账户登录后 cookie 中的`sk`值 + +- 南方周末付费全文 + - `INFZM_COOKIE`: infzm 账户登陆后的 cookie,目前只需要 `passport_session=...` 即可获取全文 diff --git a/lib/config.js b/lib/config.js index 6ac845cff3..7fc5178211 100644 --- a/lib/config.js +++ b/lib/config.js @@ -202,6 +202,9 @@ const calculateValue = () => { ipb_pass_hash: envs.EH_IPB_PASS_HASH, sk: envs.EH_SK, }, + infzm: { + cookie: envs.INFZM_COOKIE, + }, }; }; calculateValue(); diff --git a/lib/routes/infzm/news.js b/lib/routes/infzm/news.js index 5759a289b6..44662081af 100644 --- a/lib/routes/infzm/news.js +++ b/lib/routes/infzm/news.js @@ -1,3 +1,4 @@ +const config = require('@/config').value; const got = require('@/utils/got'); const timezone = require('@/utils/timezone'); const cheerio = require('cheerio'); @@ -28,26 +29,17 @@ module.exports = async (ctx) => { if (value) { description = value; } else { + const cookie = config.infzm.cookie; const response = await got({ 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)};`, + }, }); - - if (response.data.code === 200) { - 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(); - } + const $ = cheerio.load(response.data); + description = $('div.nfzm-content__content').html(); ctx.cache.set(key, description); }