DIYgod/RSSHub · error
无法找到 Body.js 脚本文件
Error message
无法找到 Body.js 脚本文件
What it means
Thrown by the zhizhuan100 report route when, after fetching the `https://www.zhizhuan100.com.cn/analysis` page and loading it with cheerio, no `<script>` tag whose `src` contains `Body.js` can be found. The route depends on that script file to locate the report HTML, so its absence aborts the handler.
Source
Thrown at lib/routes/zhizhuan100/report.ts:31
radar: [
{
source: ['www.zhizhuan100.com.cn/analysis'],
},
],
name: 'analytic',
maintainers: ['Cedaric'],
handler,
};
async function handler() {
const urlData = await ofetch('https://www.zhizhuan100.com.cn/analysis');
const $ = load(urlData);
const bodyJsUrl: string | undefined = $('script[src*="Body.js"]').attr('src');
if (!bodyJsUrl) {
throw new Error('无法找到 Body.js 脚本文件');
}
const responseData = await ofetch(bodyJsUrl, {
parseResponse: (txt) => txt,
});
const htmlMatch = responseData.match(/document\.write\('(.*)'\);/s);
if (!htmlMatch) {
throw new Error('无法找到HTML内容');
}
const htmlContent = JSON.parse(`"${htmlMatch[1]}"`);
const $content = load(htmlContent);
const listItems = $content('.w-list-item');
const items = listItems
.toArray()View on GitHub (pinned to bed535e087)
Solutions
- Open the analysis page in a browser, inspect the `<script>` tags, and update the selector (`script[src*="Body.js"]`) to match the new filename substring.
- If the HTML is now rendered client-side, switch to fetching the underlying data API the page calls (check the Network tab) instead of scraping the script.
- If the page is transiently broken, retry; if the site permanently changed, rework the scraping strategy.
Example fix
// before
const bodyJsUrl: string | undefined = $('script[src*="Body.js"]').attr('src');
// after — match the renamed script
const bodyJsUrl: string | undefined = $('script[src*="report-body"]').attr('src'); Defensive patterns
Strategy: fallback
Try / catch
let bodyJsUrl = $('script[src*="Body.js"]').attr('src');
if (!bodyJsUrl) {
// try alternative selectors before giving up
bodyJsUrl = $('script[src*="body"]').attr('src') ?? $('script:not([src])').first().text() || undefined;
}
if (!bodyJsUrl) {
throw new Error('无法找到 Body.js 脚本文件');
} Prevention
- Treat the script-selector as fragile — wrap in try/catch and log when it breaks so site changes are noticed.
- Prefer the site's data API over scraping an injected script whenever one exists.
- Add a snapshot test of the analysis page's script tags so a rename fails in CI, not production.
When it happens
Trigger: The zhizhuan100 site redesigns its analysis page and renames/removes the `Body.js` script reference; the page returns an error/interstitial instead of the normal HTML; the script tag now uses a different `src` naming that no longer contains the substring `Body.js`.
Common situations: Site frontend rebuild changes asset names; a deploy serves a placeholder page; the script is loaded dynamically (injected by JS) so it isn't present in the initial cheerio-parsed HTML; CDN/path change alters the filename.
Related errors
- 无法找到HTML内容
- Cannot get link
- Cannot extract __INITIAL_SSR_STATE__
- this route is empty, please check the original site or <a hr
- Unknown type: ${item.type}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/2b3d9e4630806413.
Report an issue: GitHub.