ImportError: No module named dupefilters

news/2024/6/26 21:18:24

报错信息:



代码:

setting:

# -*- coding: utf-8 -*-

# Scrapy settings for testscrapyredis project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     http://doc.scrapy.org/en/latest/topics/settings.html
#     http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
#     http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'testscrapyredis'

SPIDER_MODULES = ['testscrapyredis.spiders']
NEWSPIDER_MODULE = 'testscrapyredis.spiders'



# 指定使用scrapy-redis的调度器
SCHEDULER = "scrapy_redis.scheduler.Scheduler"

# 指定使用scrapy-redis的去重
DUPEFILTER_CLASS = 'scrapy_redis.dupefilters.RFPDupeFilter'

# 指定排序爬取地址时使用的队列,
# 默认的 按优先级排序(Scrapy默认),由sorted set实现的一种非FIFO、LIFO方式。
SCHEDULER_QUEUE_CLASS = 'scrapy_redis.queue.SpiderPriorityQueue'


# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = 'testscrapyredis (+http://www.yourdomain.com)'

# Obey robots.txt rules
# ROBOTSTXT_OBEY = True

# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See http://scrapy.readthedocs.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
#DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
#CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
#COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language': 'en',
}

# Enable or disable spider middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
#    'testscrapyredis.middlewares.TestscrapyredisSpiderMiddleware': 543,
#}

# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
#    'testscrapyredis.middlewares.MyCustomDownloaderMiddleware': 543,
#}

# Enable or disable extensions
# See http://scrapy.readthedocs.org/en/latest/topics/extensions.html
#EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
#}

# 在redis中保持scrapy-redis用到的各个队列,从而允许暂停和暂停后恢复,也就是不清理redis queues
SCHEDULER_PERSIST = True

# Configure item pipelines
# See http://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
   'testscrapyredis.pipelines.TestscrapyredisPipeline': 300,
    'scrapy_redis.pipelines.RedisPipeline': 400
}

# LOG等级
LOG_LEVEL = 'DEBUG'

REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379

#默认情况下,RFPDupeFilter只记录第一个重复请求。将DUPEFILTER_DEBUG设置为True会记录所有重复的请求。
DUPEFILTER_DEBUG =True

# Enable and configure the AutoThrottle extension (disabled by default)
# See http://doc.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'


pipelines:

# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html


class TestscrapyredisPipeline(object):
    def process_item(self, item, spider):
        return item

items:

# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class TestscrapyredisItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass


baidu.py:

# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import Rule
from scrapy_redis.spiders import RedisCrawlSpider
# from scrapy_redis.dupefilter import RFPDupeFilter

class BaiduSpider(RedisCrawlSpider):
    name = 'baidu'
    allowed_domains = ['baidu.com']
    # start_urls = ['http://baidu.com/']
    redis_key = 'baidu:start_urls'

    rules = (
        Rule(LinkExtractor(allow=r'baidu'), callback='parse_item', follow=True),
    )

    # def __init__(self, *args, **kwargs):
    #     domain = kwargs.pop('domain', '')
    #     self.allowed_domains = filter(None, domain.split(','))
    #     super(BaiduSpider, self).__init__(*args, **kwargs)

    def parse_item(self, response):
        i = {}
        #i['domain_id'] = response.xpath('//input[@id="sid"]/@value').extract()
        #i['name'] = response.xpath('//div[@id="name"]').extract()
        #i['description'] = response.xpath('//div[@id="description"]').extract()
        return i


未解决......






http://www.niftyadmin.cn/n/3390881.html

相关文章

树莓派 触摸屏_树莓派加装3.5寸触摸屏方法和触摸屏问题处理

近期给树莓派3B加装了3.5寸触摸屏,遇到一些问题,记录如下:一、硬件连接准备好树莓派和3.5寸触摸屏,我这里使用的是3B,其他的型号应该也能兼容。3.5寸屏幕资料如下:3.5inch RPi Display​www.lcdwiki.comhtt…

注入补丁_关注 | 信用修复打补丁,注入守信正能量

为顺应社会诉求和完善社会信用体系,建立信用修复机制,国家税务总局发布了《国家税务总局关于纳税信用修复有关事项的公告》(国家税务总局公告2019年第37号),《公告》第一条明确了19种情节轻微或未造成严重社会影响的纳税信用失信行为&#xf…

R400在Ubuntu 9.04下安装官方ATI显卡驱动

R400在Ubuntu 9.04下安装官方ATI显卡驱动 Published on 2009/10/03 by harry. 0 Comments由于之前的hp笔记本突然挂了,一咬牙换了个thinkpad r400,不过他这个显卡是 ATI Radeon HD 3470,买之前就有点担心ubuntu下的驱动问题。结果果然折腾了一…

sublime加入input函数_(1条消息)解决不能在Sublime Text3中使用input函数输入内容的问题...

刚刚在上一篇博客中说Sublime Text3如何好用,结果编程中就发现了不能在它的控制台中输入内容给input函数。要解决该问题,需要使用插件:SublimeREPL。下面是解决方法,分享出来供大家参考:1. 安装插件:ctrlsh…

一年级小学计算机课教案,小学一年级信息技术教案

中学信息技术课程的开展是为了提升学生们对信息技术学科的了解,下面是小编想跟大家分享的中学信息技术教案,欢迎大家浏览。一、指导思想与任务目标:初中阶段信息技术课程,使学生初步具备获取信息、传输信息、处理信息和应用信息的…

官方强烈推荐的ubuntu9.10更新源

给大家提供几个UBUNTU9.10的更新源,按测试速度排名.台湾代码:deb http://tw.archive.ubuntu.com/ubuntu/ karmic main universe restricted multiversedeb http://tw.archive.ubuntu.com/ubuntu/ karmic-updates universe main multiverse restricteddeb http://tw.archive.ubu…

求与下面谓词公式等值的前束范式_暨南大学离散数学周密试卷数理逻辑与集合论—参考试卷...

暨南大学离散数学周密试卷数理逻辑与集合论—参考试卷 第 1 页 共 9 A 页暨 南 大 学 考 试 试 卷得分 评阅人一、填空题(共 10 小题,每小题 2 分,共 20 分)1. 设命题 p:罗素悖论的真值为假,q:暨南大学的校训是信敏廉毅…

计算机操作系统第八章测试题及答案,《计算机基础》第八章练习题

第八章习 题一、选择题(1)中文Word编辑软件的运行环境是 CA)DOS B)WPS C)Windows D)高级语言(2)段落的标记是在输入什麽之后产生的? BA)句号 B)Enter键 C)ShiftEnter D)分页符(3)在Word编辑状态下,若要告诉左右边界,利用下列哪种方法更直接、…