fix(route): xiaohongshu puppeteer parsing
This commit is contained in:
parent
0f72967759
commit
0f275d6532
|
|
@ -13,12 +13,8 @@ const getContent = (url, cache) =>
|
|||
});
|
||||
await page.goto(url);
|
||||
await page.waitForSelector('.pc-container');
|
||||
let content = await page.content();
|
||||
|
||||
content = content.replace('"RedAppLayout":undefined,', ''); // fix json parse
|
||||
const regex = /_SSR_STATE__\S*=([\s\S]+)<\/script>/gm;
|
||||
const match = regex.exec(content);
|
||||
return JSON.parse(match[1]).Main;
|
||||
const initialSsrState = await page.evaluate(() => window.__INITIAL_SSR_STATE__);
|
||||
return initialSsrState.Main;
|
||||
} finally {
|
||||
browser.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue