Skip to content

Commit

Permalink
Merge pull request #2251 from needKVAS/dev
Browse files Browse the repository at this point in the history
Update royalroad.py
  • Loading branch information
dipu-bd authored Feb 9, 2024
2 parents a943fc7 + f9a1b56 commit cdd97d6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion sources/en/r/royalroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def read_novel_info(self):
self.novel_author = soup.find("a", {"class": "font-white"}).text.strip()
logger.info("Novel author: %s", self.novel_author)

self.novel_synopsis = self.cleaner.extract_contents(soup.find("div", {"class": "hidden-content"}))
self.novel_synopsis = self.cleaner.extract_contents(
soup.find("div", {"class": "hidden-content"})
)
logger.info("Novel synopsis: %s", self.novel_synopsis)

for tag in soup.find_all("a", {"class": "fiction-tag"}):
Expand Down Expand Up @@ -75,6 +77,16 @@ def download_chapter_body(self, chapter):
if possible_title and "Chapter" in possible_title.text:
chapter["title"] = possible_title.text.strip()

classnames = []
for style in soup.select("style"):
style = style.text.replace(" ", "").replace("\n", "")
if style.endswith("{display:none;speak:never;}"):
classnames.append(style[1:-27])

for classname in classnames:
for div in soup.find_all("p", {"class": classname}):
div.decompose()

contents = soup.select_one(".chapter-content")
self.cleaner.clean_contents(contents)
return str(contents)

0 comments on commit cdd97d6

Please sign in to comment.