{"record":{"id":"4bc480dab62d928c","repo":"jackwener/OpenCLI","slug":"could-not-find-chart-data-on-page","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/top.js","lineNumber":29,"sourceCode":"    description: 'IMDb Top 250 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', 'votes', 'genre', 'url'],\n    func: async (page, args) => {\n        const url = forceEnglishUrl('https://www.imdb.com/chart/top/');\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, 250));\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/top.js#L11-L47","documentation":"The imdb top command throws CommandExecutionError('Could not find chart data on page') when extractJsonLd(page, 'ItemList') returns null or the result lacks an array itemListElement. The Top 250 chart page loaded without a challenge, but the expected ItemList JSON-LD block holding the chart entries is missing or malformed.","triggerScenarios":"After a successful, non-challenged load of https://www.imdb.com/chart/top/ and page.wait(2), extractJsonLd(page, 'ItemList') yields no object, or ld.itemListElement is not an Array.","commonSituations":"IMDb redesigning the chart page and dropping/moving the ItemList JSON-LD, a partial render where JSON-LD hasn't been injected after only a 2-second wait, or a regional variant of the page with different markup.","solutions":["Retry the command — a slow render can leave JSON-LD missing after the fixed 2s wait.","Increase the wait time before extraction if the library allows configuration.","Check imdb.com/chart/top/ in a browser; if the structure changed, the library needs an update."],"exampleFix":"// before\nconst top = await imdbTop({ limit: 10 }); // threw: chart data missing\n// after\nawait sleep(1000); // give SPA more time, then retry once\nconst top = await retry(() => imdbTop({ limit: 10 }), { attempts: 2 });","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await imdbTop({ limit });\n} catch (e) {\n  if (/Could not find chart data/.test(e.message)) {\n    await sleep(5000);\n    return retryWithBackoff(() => imdbTop({ limit }), { attempts: 2 });\n  }\n  throw e;\n}","preventionTips":["Retry once after a short delay — JSON-LD may render after the fixed 2s wait.","Keep the library updated; IMDb chart redesigns can break ItemList extraction.","Manually inspect imdb.com/chart/top/ source when errors start occurring consistently.","Cache chart data to minimize exposure to transient rendering issues."],"tags":["scraping","json-ld","page-structure","data-extraction"],"backgroundTag":"page-structure-changed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}