jackwener/OpenCLI · error · CommandExecutionError

Jike topic page did not expose the expected data script

Error message

Jike topic page did not expose the expected data script

What it means

The topic CLI scrapes data from a <script type="application/json"> tag injected by the m.okjike.com page. When no such script element exists in the DOM, the in-page evaluate returns {reason:'missing-data-script'} and the CLI throws CommandExecutionError. This means the page did not render in the expected Next.js/SSR shape.

Source

Thrown at clis/jike/topic.js:58

    return { ok: false, reason: 'parse-error', message: e?.message || String(e) };
  }
})()
`);
        if (Array.isArray(data)) {
            if (data.length === 0) {
                throw new EmptyResultError('jike topic', `No posts were returned for topic ${args.id}. Confirm the topic ID and login state.`);
            }
            return data.slice(0, limit).map((item) => ({
                content: item.content ?? '',
                author: item.author ?? '',
                likes: item.likes ?? 0,
                comments: item.comments ?? 0,
                time: item.time ?? '',
                url: `https://web.okjike.com/originalPost/${item.id ?? ''}`,
            }));
        }
        if (data?.reason === 'missing-data-script') {
            throw new CommandExecutionError('Jike topic page did not expose the expected data script');
        }
        if (data?.reason === 'parse-error') {
            throw new CommandExecutionError(`Failed to parse Jike topic data: ${data.message || 'unknown error'}`);
        }
        throw new CommandExecutionError('Jike topic returned an unreadable payload');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-login to Jike to eliminate login-wall redirects, then retry.
  2. Open https://m.okjike.com/topics/<id> in a browser and inspect whether script[type="application/json"] still exists.
  3. Retry later if a bot-check/CAPTCHA interstitial is being served.
  4. Update the CLI/package if Jike changed the page structure permanently.

Example fix

// before
const el = document.querySelector('script[type="application/json"]');
if (!el) return { ok: false, reason: 'missing-data-script' };
// after: also try __NEXT_DATA__ by id
const el = document.querySelector('script#__NEXT_DATA__') || document.querySelector('script[type="application/json"]');
if (!el) return { ok: false, reason: 'missing-data-script' };
Defensive patterns

Strategy: retry

Validate before calling

// confirm session is live and page renders before scraping
await page.goto(url, { waitUntil: 'domcontentloaded' });
if (await page.$('script[type="application/json"]') === null) await page.reload();

Try / catch

try {
  return await runCli(['jike', 'topic', id]);
} catch (e) {
  if (/did not expose the expected data script/.test(e.message) && attempt < 3) return retryAfterLogin();
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate finds no script[type="application/json"] — e.g. the page served a login wall, an error page, a bot-check/CAPTCHA, or Jike redesigned the page to use a different data mechanism.

Common situations: Expired cookies causing a redirect to a login page; Jike front-end upgrade replacing the JSON script tag; anti-bot interstitial; network issues serving a partial/HTML error page.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3d82f8928297de27. Report an issue: GitHub.