This commit is contained in:
cwx committed 2023-05-15 10:45:47 +08:00
1 parent 03f3a5fc7c
commit 43569ed246
4 files changed
+28 -16

No files matched your search

+4 -4
View File
@@ -23,14 +23,13 @@ class RmComicSpider(scrapy.Spider):
comic['chapter_href'] = response.xpath('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/@href').extract()
list_img = []
for link in comic['chapter_href']:
list_img.append(scrapy.Request(self.main_url+link, callback=self.parse_chapter,errback=self.err))
comic['list_img'] = list_img
yield comic
yield list_img.append(scrapy.Request(self.main_url+link,meta={'item' : comic} , callback=self.parse_chapter,errback=self.err))
def err(self):
print("Error=====")
def parse_chapter(self, response):
item = response.meta['item']
data = response.xpath('//script[@id="__NEXT_DATA__"]/text()').extract_first()
str_exec="props.pageProps."
comic_name = CommonUtils.parseExec(data,str_exec+"bookName")
@@ -38,7 +37,8 @@ class RmComicSpider(scrapy.Spider):
description = CommonUtils.parseExec(data,str_exec+"description")
images = CommonUtils.parseExec(data,str_exec+"images")
chapter_api_url = CommonUtils.parseExec(data,str_exec+"chapterAPIPath")
yield ComicItem(name=comic_name,chapter=chapterName,dep=description,list_img=images)
item['list_img'] = images
yield item
def parse(self, response):
raise NotImplementedError