A toolkit for creating, debugging, and managing Legado book sources. Includes analysis tools, real book source examples, and a knowledge base built from Legado source code.
text
1. Detect encoding → 2. Fetch real HTML → 3. Query knowledge base → 4. Analyze structure → 5. Create book source
Rules should be derived from actual HTML analysis rather than assumptions.
This skill is intended for developing book sources for websites the user owns or has authorization to access. The included tools (URL analysis, HTML fetching, source uploading) should only be used on target sites with the user's explicit consent. Do not use these tools for unauthorized scraping, bypassing access controls, or accessing content without permission.
ToolPurposesearch_knowledge(query)Search knowledge baseget_css_selector_rules()CSS selector reference (paginated)get_real_book_source_examples(limit)Real book source analysis resultsget_book_source_templates(limit)Proven book source templatesread_file_paginated(path, page)Read large files with paginationlist_all_knowledge_files()List all knowledge files
ToolPurposesmart_fetch_html(url, method, body, headers, charset)Fetch HTML with encoding supportsmart_web_analyzer(html)Full page structure analysissmart_bookinfo_analyzer(html)Book info page analysissmart_toc_analyzer(html)Table of contents analysissmart_content_analyzer(html)Content page analysis
ToolPurposeedit_book_source(complete_source="JSON")Create/edit book sourcevalidate_book_source.pyValidate book source JSON (in tools/)
tools/)#ScriptDepsPurposeanalyze_url.pyrequests, bs4Website analysis (encoding + structure + search API)analyze_url.shcurlWebsite analysis (no Python required)quick_analyze.pyrequests, bs4Quick analysis with auto HTML storagejs_param_analyzer.pyrequests, bs4JS parameter/endpoint analysisvalidate_book_source.py—Book source JSON validation (no deps)upload_book_source.pyrequestsUpload book source to public image host (default: tu.406np.xyz) for shareable direct links
No Python? See
references/no_python_workflow.mdfor using host MCP tools (browser, HTTP, code execution).
Step 1: Query Knowledge Base
text
search_knowledge("CSS选择器格式 提取类型 @text @html @href @src")
get_real_book_source_examples(limit=5)
get_book_source_templates(limit=3)
Step 2: Detect Encoding (once, at start)
text
detect_charset(url="http://example.com")
"charset":"gbk" to all requestsStep 3: Fetch Real HTML
text
smart_fetch_html(url="http://example.com/search", charset="gbk")
smart_fetch_html(url="http://example.com/search", method="POST",
body="keyword={{key}}&t=1", charset="gbk")
Step 4: Analyze Structure
text
smart_web_analyzer(html="...")
smart_bookinfo_analyzer(html="...")
smart_toc_analyzer(html="...")
smart_content_analyzer(html="...")
When uncertain, ask the user rather than guessing.
edit_book_source(complete_source="完整JSON")text
CSS选择器@提取类型##正则表达式##替换内容
Extraction Types:
@text — text content (includes children)@ownText — element text only (excludes children)@html — HTML structure@textNode — text nodes@href — link URL@src — image source@js — JavaScript processingNumeric Indices:
.0 = first, .-1 = last (NOT :first-child / :last-child)Text Selection:
text.关键词 (NOT :contains())Standard list with cover:
json
{"bookList": ".book-list .item", "name": ".title@text", "bookUrl": "a@href", "coverUrl": "img@src"}
No cover on search page:
json
{"coverUrl": ""}
Lazy loading images:
json
{"coverUrl": "img@data-original||img@src"}
nextContentUrl rule: Chapter number changes → SET it. Page number only → LEAVE EMPTY.
Unsupported fields (not in Legado source):
prevContentUrl does not exist:contains() pseudo-class is not supported (use text.关键词):first-child / :last-child are not supported (use .0 / .-1)Recommended practices:
Required fields: See references/legado_data_structures.md for complete field specs from BookSource.kt, SearchRule.kt, TocRule.kt, ContentRule.kt, BookInfoRule.kt.
FileContentreferences/legado_development_guide.mdWorkflow, HTML patterns, encoding, regex, troubleshootingreferences/legado_data_structures.mdSource code analysis: data structures, rule engine, DB schemareferences/Legado书源开发完整指南.mdComprehensive development guidereferences/用户交互指南.mdCommon scenario interaction flowsreferences/方法-JS扩展类.mdJavaScript API documentationreferences/Legado书源编码处理指南.mdEncoding handling guidereferences/knowledge_base/book_sources/Real book source analysis (MD)references/book_source_database/book_sources/Book source database (JSON)
CSS Selectors: img(40x), h1(30x), div(13x), content(12x), intro(11x), h3(9x)
Extraction Types: @href(81x), @text(72x), src(60x), @html(33x), @js(25x)