jackwener/OpenCLI · error · CommandExecutionError

Could not find chart data on page

Error message

Could not find chart data on page

What it means

Thrown by the IMDb trending command when the page's JSON-LD ItemList block is missing or has no itemListElement array. The library relies on IMDb embedding an ItemList schema block for chart entries; if extraction returns nothing usable, the page structure has likely changed or the page rendered unexpectedly.

Source

Thrown at clis/imdb/trending.js:29

    description: 'IMDb Most Popular Movies',
    domain: 'www.imdb.com',
    strategy: Strategy.PUBLIC,
    browser: true,
    args: [
        { name: 'limit', type: 'int', default: 20, help: 'Number of results' },
    ],
    columns: ['rank', 'title', 'rating', 'genre', 'url'],
    func: async (page, args) => {
        const url = forceEnglishUrl('https://www.imdb.com/chart/moviemeter/');
        await page.goto(url);
        await page.wait(2);
        if (await isChallengePage(page)) {
            throw new CommandExecutionError('IMDb blocked this request', 'Try again with a normal browser session or extension mode');
        }
        // Extract the ItemList JSON-LD block which contains all chart entries
        const ld = await extractJsonLd(page, 'ItemList');
        if (!ld || !Array.isArray(ld.itemListElement)) {
            throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');
        }
        const limit = Math.max(1, Math.min(Number(args.limit) || 20, 100));
        const items = ld.itemListElement.slice(0, limit);
        return items.map((entry, index) => {
            const item = entry.item || {};
            const rating = item.aggregateRating || {};
            const genre = Array.isArray(item.genre)
                ? item.genre.join(', ')
                : String(item.genre || '');
            // Normalize relative URLs to absolute IMDb URLs
            let itemUrl = item.url || '';
            if (itemUrl && !/^https?:\/\//.test(itemUrl)) {
                itemUrl = 'https://www.imdb.com' + itemUrl;
            }
            return {
                rank: entry.position || index + 1,
                title: String(item.name || ''),
                rating: rating.ratingValue != null ? String(rating.ratingValue) : '',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command; transient render/consent pages often fix themselves on a fresh load
  2. Open IMDb trending in the connected browser and complete any consent/interstitial page, then retry
  3. Clear browser cache/cookies for imdb.com and retry with a normal session
  4. Update the CLI to the latest version to pick up scraper fixes for new IMDb markup
  5. If persistent, inspect the page's <script type="application/ld+json"> blocks and patch the extractor for the new structure

Example fix

// before
const ld = await extractJsonLd(page, 'ItemList');
if (!ld || !Array.isArray(ld.itemListElement)) {
  throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');
}
// after
let ld = await extractJsonLd(page, 'ItemList');
if (!ld || !Array.isArray(ld.itemListElement)) {
  await page.reload({ waitUntil: 'networkidle2' });
  ld = await extractJsonLd(page, 'ItemList');
}
if (!ld || !Array.isArray(ld.itemListElement)) {
  throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');
}
Defensive patterns

Strategy: retry

Validate before calling

const ld = await extractJsonLd(page, 'ItemList');
if (!ld || !Array.isArray(ld.itemListElement)) {
  await page.reload({ waitUntil: 'networkidle2' });
}

Type guard

function hasItemList(v) {
  return !!v && Array.isArray(v.itemListElement) && v.itemListElement.length > 0;
}

Try / catch

try {
  const rows = await imdb.trending({ limit: 20 });
} catch (e) {
  if (e.message.includes('Could not find chart data')) {
    // wait and retry once, or surface 'IMDb structure changed'
  }
}

Prevention

When it happens

Trigger: extractJsonLd(page, 'ItemList') returns null/undefined or ld.itemListElement is not an array after isChallengePage(page) is false, i.e. the page loaded but lacks the ItemList JSON-LD script.

Common situations: IMDb redesigns their chart page and removes/renames the ItemList JSON-LD block; an A/B-test variant page renders a different structure; a consent/interstitial page loads without the schema; stale cached HTML served to the connected browser.

Related errors


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