1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| import {parse} from "node-html-parser";
|
| export interface INextProps {
| initialState?: {
| item?: {
| detail?: {
| item?: any
| }
| },
| itemsState?: {
| items?: {
| item?: any
| }
| }
| },
| pageProps?: any
| }
|
| export function queryNextData(htmlStr: string): INextProps {
| try {
| return JSON.parse(parse(htmlStr).querySelector('#__NEXT_DATA__[type*="application/json"]').text?.trim())?.props || {};
| } catch (e) {
| return {};
| }
| }
|
|