DIYgod/RSSHub · error · Error

Cannot find the script with data-iso-key="_0"

Error message

Cannot find the script with data-iso-key="_0"

What it means

Thrown when the ScienceDirect calls-for-papers page contains no <script data-iso-key="_0"> element whose text the route can harvest. ScienceDirect embeds its page data as a JSON blob inside such an ISO (Isomorphic) script tag; absence of the tag means the SSR payload structure changed or a non-content page was returned.

Source

Thrown at lib/routes/sciencedirect/call-for-paper.tsx:34

            source: ['sciencedirect.com'],
        },
    ],
    name: 'Call for Papers',
    maintainers: ['etShaw-zh'],
    handler,
    url: 'sciencedirect.com/browse/calls-for-papers',
    description: '`sciencedirect.com/browse/calls-for-papers?subject=education` -> `/sciencedirect/call-for-paper/education`',
};

async function handler(ctx) {
    const { subject = '' } = ctx.req.param();
    const apiUrl = `https://www.sciencedirect.com/browse/calls-for-papers?subject=${subject}`;
    const response = await got(apiUrl);
    const $ = load(response.body);

    const scriptJSON = $('script[data-iso-key="_0"]').text();
    if (!scriptJSON) {
        throw new Error('Cannot find the script with data-iso-key="_0"');
    }

    let data;
    try {
        data = JSON.parse(JSON.parse(scriptJSON));
    } catch (error: any) {
        throw new Error(`Failed to parse embedded script JSON: ${error.message}`, { cause: error });
    }

    const cfpList = data?.callsForPapers?.list || [];
    if (!cfpList.length) {
        throw new Error('No Calls for Papers found');
    }

    const items = cfpList.map((cfp) => {
        const link = `https://www.sciencedirect.com/special-issue/${cfp.contentId}/${cfp.url}`;
        const description = renderToString(
            <div>

View on GitHub (pinned to bed535e087)

Solutions

  1. Fetch the URL with a browser UA and confirm a script[data-iso-key] element is present; note any new key value.
  2. If the key changed, update the selector to the new data-iso-key attribute.
  3. If a consent/anti-bot page is returned, add the necessary cookies/headers or use config.trueUA.
  4. Surface the HTTP status / partial body in the error to distinguish 'no script' from 'blocked'.

Example fix

// before
const scriptJSON = $('script[data-iso-key="_0"]').text();
if (!scriptJSON) {
    throw new Error('Cannot find the script with data-iso-key="_0"');
}

// after — search all data-iso scripts for the one carrying callsForPapers
let scriptJSON = '';
let isoKey = '_0';
$('script[data-iso-key]').each((_, el) => {
    const txt = $(el).text();
    if (txt.includes('callsForPapers')) {
        scriptJSON = txt;
        isoKey = $(el).attr('data-iso-key')!;
        return false;
    }
});
if (!scriptJSON) {
    throw new Error('Cannot find a data-iso script carrying callsForPapers data');
}
Defensive patterns

Strategy: fallback

Validate before calling

// Verify the data-iso script presence with a browser-like UA before parsing.
async function hasIsoScript(subject: string): Promise<boolean> {
    const html = await got(`https://www.sciencedirect.com/browse/calls-for-papers?subject=${subject}`, { headers: { 'user-agent': config.trueUA } }).then((r) => r.body);
    return /<script[^>]*data-iso-key=/.test(html);
}

Type guard

const hasIsoPayload = ($: cheerio.CheerioAPI): boolean =>
    $('script[data-iso-key]').toArray().some((el) => $(el).text().length > 0);

Try / catch

try {
    return await handler(ctx);
} catch (e) {
    if (e instanceof Error && /Cannot find the script with data-iso-key/.test(e.message)) {
        // retry once with a full browser UA / consent cookies
        return await handlerWithBrowserHeaders(ctx);
    }
    throw e;
}

Prevention

When it happens

Trigger: GET https://www.sciencedirect.com/browse/calls-for-papers?subject={subject} returns HTML in which no script has data-iso-key="_0". $('script[data-iso-key="_0"]').text() is the empty string, so scriptJSON is falsy and the guard throws.

Common situations: ScienceDirect changed its isomorphic data-iso key scheme; the response was a bot-detection/consent page rather than the real page; a regional redirect served a different shell without the ISO blob; the subject value triggered an error page.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/e435d33ec773bfa4. Report an issue: GitHub.