scrapy爬取小说(新笔趣阁)

最近刚接触scrapy框架,学了一天之后直接用爬小说练手,有不妥之处愿大佬多多指点
新笔趣阁地址:
https://www.xbiquge.la/

spiders中的xbiquge.py

from time import sleep

import scrapy
import re

class XbiqugeSpider(scrapy.Spider):
    name = 'xbiquge'
    allowed_domains = ['biquge7.com']   #根据需要更改
    #下面的网页地址为小说的第一章的url
    start_urls = ['https://www.biquge7.com/book/5/1.html']  #可以更改
    def parse(self, response):
        item ={
   }
        # title = response.xpath("//div[@class='bookname']/h1/text()").extract_first()
        title = response.xpath("//div[@class='content']/h1/text()").extract_first()
        print(title)
		#如果标题不符合正常的定义规则,则需要自定义
		#此处注释的都是以前爬的时候自己定义的
        # item["title"] = title.replace('京察风云 ','') 
        # item["title"] = re.findall('(?<=\.).*$',title)[0]
        try:
            id = re.findall(r'\d+'
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值