【Narou.rb】Was “Novel has been deleted” a lie? The real culprit behind the download error was “just a single line break”
“Narou.rb" is a Web novel management tool that I personally love using. Running inside a Docker container, it’s a reliable partner that automatically collects daily updates and converts them into e-books. However, the other day, when I tried to download a specific new novel, it was stubbornly rejected.
The logs mercilessly displayed the following:
[ERROR] 小説が削除されているか非公開な可能性があります [ERROR] https://ncode.syosetu.com/n8281jr/ の目次データが取得出来ませんでした
It would be easy to give up and think, “Ah, it must have been deleted." However, when accessing it via a browser, that novel was actively serialized and doing well. This was a challenge letter from the server. This record details how I tracked down the cause of Narou.rb’s false positive—thinking it was “deleted"—and resolved it by modifying the configuration file (YAML).
Mission: Clear the False Accusation and Resume Collection
The objective this time is to “correctly recognize an existing novel and make the download succeed."
In web scraping tools, acquisition failures due to target site design changes or fluctuations in HTML structure are inevitable. However, since the error message stated it was “deleted," the tool judged that “the page itself could not be found (or could not be parsed)."
The goal (quantitative target) is as follows:
- Successful download of the target novel (ID: n8281jr) (100% progress)
- Robust configuration that won’t throw errors even for novels with similar HTML structures in the future
Investigation Begins: Why Is It “Invisible"?
First, I checked the connection from the server (Docker container) to the internet. Using the curl command, I tried accessing Narou’s server directly from inside the container.
docker-compose exec narou curl -I https://ncode.syosetu.com/n8281jr/
The result was HTTP/1.1 200 OK. There were no problems with the communication path, and it was not blocked by a WAF (firewall) like Cloudflare. In other words, the HTML data had arrived safely.
The fact that data arrived yet could not be “acquired" means that the “map for page analysis (regular expressions)" held by Narou.rb and the actual “terrain (HTML)" were mismatched.
Suspects Under Investigation
At first, I suspected changes in the format of the table of contents list or update dates. Were there line breaks next to the dates? Did the tag class names change? I carefully reviewed subtitles (table of contents definition) and nu (update date definition) in the configuration file (ncode.syosetu.com.yaml), but lacked a smoking gun.
However, light shines nearest the candlestick. The parsing failed at the most fundamental part: the “title."
Solution: The Pitfall Called Line Breaks
In Narou.rb’s configuration file (YAML), the rule for fetching titles was written as follows:
Before Modification (Problematic Description)
# タイトル t: <h1 class="p-infotop-title"><a href=".+?">(?<title>.+?)</a></h1>
As a regular expression, this expects that “everything from the h1 tag to the closing a tag is connected in a single line." This is because the dot (.) in regular expressions normally only matches “any character except a line break."
However, when I checked the HTML source of the novel that failed to download this time, it looked like this:
Actual HTML
<h1 class="p-infotop-title"> <a href="..."> 崩壊世界の魔法杖職人 </a> </h1>
There are line breaks between the h1 and a tags, and before and after the title. Because of this “single line break," the regular expression above (.+?) failed to match, leading Narou.rb to the false conclusion that “title not found = this is not a novel page = it must have been deleted."
Applying the Patch
Once the cause is known, fixing it is easy. We just need to make the YAML description support “multiple lines (line breaks)." Using the volumes feature of docker-compose, we mount the modified YAML file into the container.
After Modification (Fixed YAML)
# タイトル # |- を使うことで、改行を含んだ文字列として定義する t: |- <h1 class="p-infotop-title"> <a href=".+?">(?<title>.+?)</a> </h1>
By inserting line breaks to match the HTML structure (or using a regular expression containing line breaks like [\s\S]+?), the parser can now correctly recognize the title.
Applying this modified file, I executed the download command again.
docker-compose exec narou narou download n8281jr
As a result, as if to belie its previous stubborn rejections, the download progress bar began to run.
Summary from Nando Kobo
This trouble was not a system bug, but a collision between “overly strict definitions" and “HTML fluctuations."
- Doubt error logs: Even if told “it has been deleted," first verify its existence using a browser and curl.
- The trap of regular expressions: The . (dot) is not almighty. In HTML parsing, “line breaks" can always become an enemy.
- YAML flexibility: By slightly rewriting the definition file, the tool springs back to life.
Even on a narrow server like a walk-in closet (Nando), a comfortable reading environment is maintained by accumulating such small “repairs." If you ever encounter a phenomenon where “only a certain novel won’t download," please definitely suspect the “regular expression around the title" in the definition file.
Wishing you a good server life.