-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add site https://www.xiaoshubao.net/
See: #1593
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use strict"; | ||
|
||
parserFactory.register("xiaoshubao.net", () => new XiaoshubaoParser()); | ||
|
||
class XiaoshubaoParser extends Parser{ | ||
constructor() { | ||
super(); | ||
} | ||
|
||
async getChapterUrls(dom) { | ||
return [...dom.querySelectorAll("#list > dl > dd a")] | ||
.map(a => util.hyperLinkToChapter(a)); | ||
} | ||
|
||
findContent(dom) { | ||
return dom.querySelector("#content"); | ||
} | ||
|
||
extractTitleImpl(dom) { | ||
return dom.querySelector(".booktitle h1"); | ||
} | ||
|
||
extractAuthor(dom) { | ||
let authorLabel = dom.querySelector("#info p a"); | ||
return authorLabel?.textContent ?? super.extractAuthor(dom); | ||
} | ||
|
||
extractLanguage() { | ||
return "zh"; | ||
} | ||
|
||
removeUnwantedElementsFromContentElement(element) { | ||
util.removeChildElementsMatchingCss(element, "p.to_nextpage"); | ||
super.removeUnwantedElementsFromContentElement(element); | ||
} | ||
|
||
findChapterTitle(dom) { | ||
return dom.querySelector(".bookname h1"); | ||
} | ||
|
||
findCoverImageUrl(dom) { | ||
return util.getFirstImgSrc(dom, "#fmimg"); | ||
} | ||
|
||
async fetchChapter(url) { | ||
return this.walkPagesOfChapter(url, this.moreChapterTextUrl); | ||
} | ||
|
||
moreChapterTextUrl(dom) { | ||
let nextUrl = dom.querySelector("p.to_nextpage a"); | ||
return (nextUrl != null && nextUrl.href.includes("_")) | ||
? nextUrl.href | ||
: null; | ||
} | ||
|
||
getInformationEpubItemChildNodes(dom) { | ||
return [...dom.querySelectorAll("#intro")]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters