diff --git a/lib/v2/ifeng/feng.js b/lib/v2/ifeng/feng.js
index de417a642..005c3cbc2 100644
--- a/lib/v2/ifeng/feng.js
+++ b/lib/v2/ifeng/feng.js
@@ -1,71 +1,69 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const { JSDOM } = require('jsdom');
-const utils = require('./utils');
+const { extractDoc, renderVideo } = require('./utils');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
- const id = ctx.params.id;
- const type = ctx.params.type;
- const userResponse = await got({
- method: 'get',
- url: `https://shankapi.ifeng.com/winter/ishare/getAccountInfo/${id}`,
+ const { id, type } = ctx.params;
+ const { data: userResponse } = await got(`https://ishare.ifeng.com/mediaShare/home/${id}/media`, {
headers: {
Referer: `https://feng.ifeng.com/author/${id}`,
},
});
- const contentResponse = await got({
- method: 'get',
- url: `https://shankapi.ifeng.com/season/ishare/getShareListData/${id}/${type}/1/ifengnewsh5/getListData`,
+ const { data: contentResponse } = await got(`https://shankapi.ifeng.com/season/ishare/getShareListData/${id}/${type}/1/ifengnewsh5/getListData`, {
headers: {
Referer: `https://feng.ifeng.com/author/${id}`,
},
});
- const userData = userResponse.data.data.data;
- const contentData = JSON.parse(contentResponse.data.match(/"data":(\[(.*?)\])/)[1]);
+ const $ = cheerio.load(userResponse);
+ const { sockpuppetInfo: allData } = JSON.parse(
+ $('script')
+ .text()
+ .match(/var allData = (.*?);/)[1]
+ );
+ const { data: contentData } = JSON.parse(contentResponse.match(/getListData\((.*)\)/)[1]);
+ const { weMediaName: mediaName } = allData;
+
+ const list = contentData.map((item) => ({
+ title: item.title,
+ pubDate: timezone(parseDate(item.newsTime), +8),
+ author: mediaName,
+ link: `https:${item.url}`,
+ }));
- const mediaName = userData.weMediaName;
const items = await Promise.all(
- (contentData || []).map(async (item) => {
- const link = `https:${item.url}`;
- const simple = {
- title: item.title,
- description: `${item.title}`,
- pubDate: timezone(parseDate(item.newsTime), +8),
- author: mediaName,
- link,
- };
+ list.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const { data: response } = await got(item.link);
+ const $ = cheerio.load(response);
- const details = await ctx.cache.tryGet(`ifeng:feng:${link}`, async () => {
- const response = await got(link);
- const $ = cheerio.load(response.data);
+ const allData = JSON.parse(
+ $('script')
+ .text()
+ .match(/var allData = ({.*?});/)[1]
+ );
if (type === 'doc') {
- const dom = new JSDOM(`