{"record":{"id":"26378734edc51395","repo":"jackwener/OpenCLI","slug":"could-not-find-chart-data-on-page-263787","errorCode":null,"errorMessage":"Could not find chart data on page","messagePattern":"Could not find chart data on page","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/imdb/trending.js","lineNumber":29,"sourceCode":"    description: 'IMDb Most Popular Movies',\n    domain: 'www.imdb.com',\n    strategy: Strategy.PUBLIC,\n    browser: true,\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Number of results' },\n    ],\n    columns: ['rank', 'title', 'rating', 'genre', 'url'],\n    func: async (page, args) => {\n        const url = forceEnglishUrl('https://www.imdb.com/chart/moviemeter/');\n        await page.goto(url);\n        await page.wait(2);\n        if (await isChallengePage(page)) {\n            throw new CommandExecutionError('IMDb blocked this request', 'Try again with a normal browser session or extension mode');\n        }\n        // Extract the ItemList JSON-LD block which contains all chart entries\n        const ld = await extractJsonLd(page, 'ItemList');\n        if (!ld || !Array.isArray(ld.itemListElement)) {\n            throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');\n        }\n        const limit = Math.max(1, Math.min(Number(args.limit) || 20, 100));\n        const items = ld.itemListElement.slice(0, limit);\n        return items.map((entry, index) => {\n            const item = entry.item || {};\n            const rating = item.aggregateRating || {};\n            const genre = Array.isArray(item.genre)\n                ? item.genre.join(', ')\n                : String(item.genre || '');\n            // Normalize relative URLs to absolute IMDb URLs\n            let itemUrl = item.url || '';\n            if (itemUrl && !/^https?:\\/\\//.test(itemUrl)) {\n                itemUrl = 'https://www.imdb.com' + itemUrl;\n            }\n            return {\n                rank: entry.position || index + 1,\n                title: String(item.name || ''),\n                rating: rating.ratingValue != null ? String(rating.ratingValue) : '',","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/imdb/trending.js#L11-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the command; transient render/consent pages often fix themselves on a fresh load","Open IMDb trending in the connected browser and complete any consent/interstitial page, then retry","Clear browser cache/cookies for imdb.com and retry with a normal session","Update the CLI to the latest version to pick up scraper fixes for new IMDb markup","If persistent, inspect the page's <script type=\"application/ld+json\"> blocks and patch the extractor for the new structure"],"exampleFix":"// before\nconst ld = await extractJsonLd(page, 'ItemList');\nif (!ld || !Array.isArray(ld.itemListElement)) {\n  throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');\n}\n// after\nlet ld = await extractJsonLd(page, 'ItemList');\nif (!ld || !Array.isArray(ld.itemListElement)) {\n  await page.reload({ waitUntil: 'networkidle2' });\n  ld = await extractJsonLd(page, 'ItemList');\n}\nif (!ld || !Array.isArray(ld.itemListElement)) {\n  throw new CommandExecutionError('Could not find chart data on page', 'IMDb may have changed their page structure');\n}","handlingStrategy":"retry","validationCode":"const ld = await extractJsonLd(page, 'ItemList');\nif (!ld || !Array.isArray(ld.itemListElement)) {\n  await page.reload({ waitUntil: 'networkidle2' });\n}","typeGuard":"function hasItemList(v) {\n  return !!v && Array.isArray(v.itemListElement) && v.itemListElement.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await imdb.trending({ limit: 20 });\n} catch (e) {\n  if (e.message.includes('Could not find chart data')) {\n    // wait and retry once, or surface 'IMDb structure changed'\n  }\n}","preventionTips":["Keep the CLI updated for IMDb markup changes","Complete consent/interstitial pages in the connected browser before running","Retry once on failure before escalating","Verify JSON-LD blocks exist when IMDb redesigns occur"],"tags":["scraping","dom","json-ld","page-structure"],"backgroundTag":"scraper-page-structure-changed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}