Overview
This node fetches multiple sequential chapters from the RoyalRoad website starting from a specified chapter URL. It combines the HTML content of these chapters into a single output, either as a binary HTML file or as an HTML string within JSON. This is useful for users who want to aggregate several chapters of a web novel or story hosted on RoyalRoad for offline reading, archiving, or further processing.
Practical examples:
- Downloading the first 10 chapters of a RoyalRoad fiction to read offline.
- Aggregating chapters into a single HTML document for conversion to other formats (e.g., PDF or eBook).
- Extracting author notes and chapter content for analysis or display in custom applications.
Properties
| Name | Meaning |
|---|---|
| Start Chapter URL | The URL of the first RoyalRoad chapter to start fetching from. |
| Number of Chapters | How many consecutive chapters to fetch starting from the given URL (1 to 1000). |
| Start Chapter Index | The 1-based index of the chapter at which to start including content (useful to skip initial chapters). |
| Output | Format of the output: either a binary HTML file or an HTML string embedded in JSON. |
| File Name | The name of the generated HTML file when outputting as a binary file (default: "royalroad.html"). |
Output
The node outputs data in two possible formats depending on the selected "Output" property:
Binary File (HTML): Outputs a single binary file containing the combined HTML of all fetched chapters. The binary data represents a complete HTML document styled with some custom CSS for tables inside chapters. The output includes metadata fields such as the original URL, number of requested chapters, starting chapter index, number of chapters actually fetched, and a preview snippet of the last chapter's HTML content.
String (HTML) in JSON: Outputs a JSON object containing the combined HTML content as a string under the
bookfield, along with metadata similar to the binary output (URL, requested chapters, start chapter, fetched chapters, and full last chapter HTML).
In both cases, the JSON output includes:
url: The starting chapter URL.requestedChapters: Number of chapters requested to fetch.startChapter: The chapter index from which content inclusion started.fetchedChapters: Actual number of chapters successfully fetched.lastChapterPreview(binary output) orlastChapterHtml(JSON output): A preview or full HTML of the last fetched chapter.
If binary output is selected, the combined HTML is stored as a binary file with MIME type text/html; charset=utf-8.
Dependencies
- The node uses the
fetchAPI to retrieve chapter pages from RoyalRoad. - It relies on the
cheeriolibrary to parse and extract HTML content from fetched pages. - No external API keys or authentication are required since it scrapes publicly accessible web pages.
- The node sets a custom User-Agent header to identify itself politely.
- It handles HTTP 429 (Too Many Requests) by retrying after a short delay.
- Requires n8n environment capable of running JavaScript with network access.
Troubleshooting
- HTTP Errors: If the node throws errors like
HTTP 404orHTTP 429, it means the URL is invalid or the server is rate-limiting requests. Verify the URL correctness and consider reducing the number of chapters fetched or adding delays between executions. - Missing URL: The node requires a valid starting chapter URL. Omitting this will cause an error.
- Partial Fetching: If fewer chapters are fetched than requested, it usually means there are no more "next" chapters available from the last fetched page.
- Malformed HTML: If the output HTML looks broken, it might be due to changes in RoyalRoad’s page structure. The node depends on specific CSS selectors (
h1.font-white,.chapter-inner,.portlet-body.author-note) that may change over time. - Binary Output Issues: Ensure the file name provided is valid and the environment supports binary data handling.