{"record":{"id":"ca05a7d08842bd78","repo":"DIYgod/RSSHub","slug":"could-not-locate-initials-script-on-page","errorCode":null,"errorMessage":"Could not locate initials script on page","messagePattern":"Could not locate initials script on page","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/xhamster/index.ts","lineNumber":110,"sourceCode":"        meta += `${meta ? ' · ' : ''}<strong>Views:</strong> ${views}`;\n    }\n\n    return `\n        <img src=\"${thumb}\" alt=\"${video.title}\" style=\"max-width:100%\" />\n        <p>${meta}</p>\n    `.trim();\n}\n\nasync function handler(ctx) {\n    const { creators } = ctx.req.param();\n    const pageUrl = `https://xhamster.com/creators/${encodeURIComponent(creators)}/newest`;\n\n    const response = await got(pageUrl);\n\n    const $ = load(response.data);\n    const initialsRaw = $('#initials-script').text();\n    if (!initialsRaw) {\n        throw new Error('Could not locate initials script on page');\n    }\n\n    let initials: Initials;\n    try {\n        initials = extractInitials(initialsRaw);\n    } catch {\n        throw new Error('Failed to parse page data');\n    }\n\n    const creatorName = initials.infoComponent?.pornstarTop?.name ?? creators;\n    const videos = initials.trendingVideoSectionComponent?.videoListProps?.videoThumbProps ?? [];\n\n    const items = videos.map((video) => ({\n        title: `${video.title}${video.isUHD ? ' [4K]' : ''}`,\n        link: video.pageURL,\n        pubDate: video.created ? parseDate(video.created * 1000) : undefined,\n        author: creatorName,\n        description: renderDescription(video),","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/xhamster/index.ts#L92-L128","documentation":"The xhamster handler loads the creator page and reads the text of the #initials-script element; if it is empty the page did not carry the expected JSON bootstrap blob. This usually means xhamster served a different page (block, age gate, regional redirect, bot challenge) than the one expected.","triggerScenarios":"got(pageUrl) returns HTML in which $('#initials-script').text() is empty — index.ts:108-110. Happens when the route is geo/IP blocked, Cloudflare/challenge interposes, or xhamster renamed the script tag.","commonSituations":"Running RSSHub from a region/IP xhamster blocks; xhamster deployed a new front-end that no longer emits #initials-script; response was an error/age-gate page.","solutions":["Fetch https://xhamster.com/creators/<slug>/newest from the RSSHub host and confirm the #initials-script tag exists in the raw HTML.","Route RSSHub egress through a region/IP that xhamster serves normally.","If the tag was renamed, update the selector at index.ts:108 and report to the maintainer (eve2ptp)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the page carries the bootstrap script before parsing\nconst resp = await got(pageUrl);\nconst $ = load(resp.data);\nif (!$('#initials-script').length || !$('#initials-script').text()) {\n    throw new Error('xhamster did not serve the expected page (blocked or template changed)');\n}","typeGuard":"function isXhamsterNoScriptError(e: unknown): boolean {\n    return e instanceof Error && /Could not locate initials script on page/i.test(e.message);\n}","tryCatchPattern":"try {\n    return await xhamsterHandler(ctx);\n} catch (e) {\n    if (isXhamsterNoScriptError(e)) {\n        // likely geo/IP block — retry via proxy or return a clear message\n        return ctx.json({ error: 'xhamster page unavailable from this host (blocked?)' }, 502);\n    }\n    throw e;\n}","preventionTips":["Verify raw HTML from the RSSHub host contains #initials-script before relying on the route.","Use a proxy/egress IP that xhamster serves to avoid bot challenges.","Pin a sample page fixture in tests so a template rename fails CI, not production."],"tags":["xhamster","scraping","html-structure","geo-block","nsfw"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}