43 lines
2.3 KiB
Python
43 lines
2.3 KiB
Python
from common.Constant import pathStr
|
|
from common.Comic import ListComic
|
|
from common.Comic import Comic
|
|
from common.BaseComicEntity import baseComic
|
|
from utils.NetUtils import htmlUtils
|
|
|
|
class comicEntity:
|
|
@classmethod
|
|
def downladsComcis(cls,url):
|
|
str_xpath='//script[@id="__NEXT_DATA__"]/text()'
|
|
str_exec="props.pageProps.books"
|
|
books = htmlUtils.setXpathData(url,xpath=str_xpath,num=0,exec=str_exec)
|
|
ListComic.setListComicName(books,"name")
|
|
ListComic.setListComicChapterLink(books,"id",start_add=pathStr.getBaseUrl(url)+"/books/")
|
|
ListComic.setListComicUpdateAt(books,"updatedAt")
|
|
is_next = True
|
|
while is_next:
|
|
is_next = baseComic.updateComics(chapters_xpath='//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()')
|
|
cls.oneComic()
|
|
|
|
@classmethod
|
|
def oneComic(cls,sleep=None):
|
|
c_url = Comic.getCurrentDownLink()
|
|
if c_url == None: return None
|
|
title = htmlUtils.getXpathData('//div[@class="col"]/h5/text()',url=c_url,num=0,update=True)
|
|
#别名
|
|
#alias = htmlUtils.xpathData('//span[contains(@class,"bookid_alias")]/text()',num=1)
|
|
icon = htmlUtils.getXpathData('//img[@class="img-thumbnail"]/@src',num=0)
|
|
author = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[1]/text()',num=1)
|
|
tags = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[3]/b/text()',num=0)
|
|
action = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[2]/text()',num=1)
|
|
dep = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[4]/text()',num=1)
|
|
update_date = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[5]/small/text()',num=1)
|
|
chapters = htmlUtils.getXpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()')
|
|
chapter_href = htmlUtils.getXpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/@href')
|
|
|
|
baseComic.oneComic(url=c_url,title=title,author=author,
|
|
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
|
genre="韩漫",age_rating="R18+")
|
|
|
|
@classmethod
|
|
def start(cls,url):
|
|
cls.downladsComcis(url) |