# -*- coding: utf-8 -*-
import scrapy
from ..items import BookItem
class NovelSpider(scrapy.Spider):
name = 'novel'
allowed_domains = ['readnovel.com']
start_urls = ['https://www.readnovel.com/free/all']
def parse(self, response):
divs = response.xpath('//div[@class="book-info"]')
for div in divs:
# 小说名称
name = div.xpath('h3/a/text()').extract_first('')
# 小说作者
author = div.xpath('h4/a/text()').extract_first('')
# 小说类型
novel_type = div.xpath('p/span[@class="org"]/text()').extract_first('')
# 小说状态
status = div.xpath('p/span[@class="red"]/text()').extract_first('')
# 小说字数
numbers = div.xpath('p/span[@class="b
scrapy框架写入json数据
最新推荐文章于 2023-02-03 02:31:09 发布