fix: [Xiaohongshu] remove Dom object from description (#4594)

This commit is contained in:
NeverBehave 2020-04-28 11:46:11 -04:00 committed by GitHub
parent 87e06feb49
commit 1ddc2b30e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -1,13 +1,11 @@
const { getContent } = require('@/routes/xiaohongshu/util');
const JSON5 = require('json5');
module.exports = async (ctx) => {
const url = `https://www.xiaohongshu.com/board/${ctx.params.board_id}`;
const content = await getContent(url);
const regex = /_SSR_STATE__\S*=([\s\S]+)<\/script>/gm;
const match = regex.exec(content);
const main = JSON5.parse(match[1]).Main;
const main = JSON.parse(match[1]).Main;
const albumInfo = main.albumInfo;
const title = `${albumInfo.name}`;

View File

@ -1,7 +1,6 @@
const { getContent } = require('@/routes/xiaohongshu/util');
const cheerio = require('cheerio');
const JSON5 = require('json5');
module.exports = async (ctx) => {
const userId = ctx.params.user_id;
@ -10,10 +9,10 @@ module.exports = async (ctx) => {
const content = await getContent(url);
const $ = cheerio.load(content);
const description = $('head title');
const description = $('head title').html();
const regex = /_SSR_STATE__\S*=([\s\S]+)<\/script>/gm;
const match = regex.exec(content);
const main = JSON5.parse(match[1]).Main;
const main = JSON.parse(match[1]).Main;
const userDetail = main.userDetail;
if (category === 'notes') {
const list = main.notesDetail;