Skip to content

Commit

Permalink
Added new sources
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZFix committed Oct 27, 2023
1 parent 0a116ef commit 5e6d9f8
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
60 changes: 60 additions & 0 deletions sources/zh/shw5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
import logging

from lncrawl.core.crawler import Crawler

logger = logging.getLogger(__name__)


class Shw5Crawler(Crawler):
base_url = [
"https://www.shw5.cc/",
"https://www.bq99.cc/",
"https://www.p2wt.com/",
]

def read_novel_info(self):
logger.debug("Visiting %s", self.novel_url)
soup = self.get_soup(self.novel_url)

possible_title = soup.select_one(".book h1")
assert possible_title, "No novel title"
self.novel_title = possible_title.text
logger.info("Novel title: %s", self.novel_title)

possible_novel_cover = soup.select_one('.book img')
if possible_novel_cover:
self.novel_cover = self.absolute_url(possible_novel_cover["src"])
logger.info("Novel cover: %s", self.novel_cover)

possible_synopsis = soup.select_one('.intro dd')
if possible_synopsis:
self.novel_synopsis = possible_synopsis.text
logger.info("Novel synopsis %s", self.novel_synopsis)

possible_novel_author = soup.select_one('.book .small span')
if possible_novel_author:
self.novel_author = possible_novel_author.text
logger.info("Novel author: %s", self.novel_author)

volumes = set([])
chapters = soup.select_one('.listmain')
for a in chapters.find_all("a", rel=False):
ch_id = len(self.chapters) + 1
vol_id = 1 + len(self.chapters) // 100
volumes.add(vol_id)
self.chapters.append(
{
"id": ch_id,
"volume": vol_id,
"title": a.text,
"url": self.absolute_url(a["href"]),
}
)

self.volumes = [{"id": x, "title": ""} for x in volumes]

def download_chapter_body(self, chapter):
soup = self.get_soup(chapter["url"])
contents = soup.select_one("#chaptercontent")
return self.cleaner.extract_contents(contents)
55 changes: 55 additions & 0 deletions sources/zh/trxs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
import logging

from lncrawl.core.crawler import Crawler

logger = logging.getLogger(__name__)


class TrxsCrawler(Crawler):
base_url = "https://trxs.cc/"

def read_novel_info(self):
logger.debug("Visiting %s", self.novel_url)
soup = self.get_soup(self.novel_url, encoding='gb2312')

possible_title = soup.select_one(".book_info h1")
assert possible_title, "No novel title"
self.novel_title = possible_title.text
logger.info("Novel title: %s", self.novel_title)

possible_novel_cover = soup.select_one('.book_info img')
if possible_novel_cover:
self.novel_cover = self.absolute_url(possible_novel_cover["src"])
logger.info("Novel cover: %s", self.novel_cover)

possible_synopsis = soup.select_one('.book_info p')
if possible_synopsis:
self.novel_synopsis = possible_synopsis.text
logger.info("Novel synopsis %s", self.novel_synopsis)

possible_novel_author = soup.select_one('.book_info a')
if possible_novel_author:
self.novel_author = possible_novel_author.text
logger.info("Novel author: %s", self.novel_author)

volumes = set([])
for a in soup.select(".book_list a"):
ch_id = len(self.chapters) + 1
vol_id = 1 + len(self.chapters) // 100
volumes.add(vol_id)
self.chapters.append(
{
"id": ch_id,
"volume": vol_id,
"title": a.text,
"url": self.absolute_url(a["href"]),
}
)

self.volumes = [{"id": x, "title": ""} for x in volumes]

def download_chapter_body(self, chapter):
soup = self.get_soup(chapter["url"], encoding='gb2312')
contents = soup.select_one(".read_chapterDetail")
return self.cleaner.extract_contents(contents)

0 comments on commit 5e6d9f8

Please sign in to comment.