Skip to content

Commit

Permalink
Added new source: NovelRare.com
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZFix committed Oct 7, 2024
1 parent 827d8ac commit fd0f9f4
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions sources/en/n/novelrare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
import logging

from lncrawl.core.crawler import Crawler

logger = logging.getLogger(__name__)


class NovelrareCrawler(Crawler):
base_url = "https://novelrare.com/"

def read_novel_info(self):
soup = self.get_soup(self.novel_url)

possible_title = soup.select_one("#manga-title h1")
if possible_title:
self.novel_title = possible_title.get_text(strip=True)

logger.info("Novel title: %s", self.novel_title)

possible_synopsis = soup.select_one("div[aria-labelledby='manga-info'] p")
if possible_synopsis:
self.novel_synopsis = possible_synopsis.get_text()

img_src = soup.select_one("div.summary_image img")
if img_src:
self.novel_cover = self.absolute_url(img_src["src"])

chapters_table = soup.select_one("div.listing-chapters_wrap")
for a in reversed(
chapters_table.find_all("a", class_=lambda x: x != "c-new-tag")
):
chap_id = 1 + (len(self.chapters))

self.chapters.append(
{
"id": chap_id,
"title": a.text.strip(),
"url": self.absolute_url(a['href'])
}
)

def download_chapter_body(self, chapter):
soup = self.get_soup(chapter["url"])
content = soup.select_one("div.text-left")
return self.cleaner.extract_contents(content)

0 comments on commit fd0f9f4

Please sign in to comment.