推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
nexus6
V2EX  ›  Python

scrapy 自己写的 filter 无法加载

  •  
  •   nexus6 ·
    NexusRJ · Nov 25, 2015 · 3412 views
    This topic created in 3962 days ago, the information mentioned may be changed or developed.
    自己实现了一个过滤器方法 custom_filter , settings 中设置
    DUPEFILTER_CLASS = 'crawls.spiders.custom_filter'

    运行项目时提示'module' object has no attribute 'from_settings'
    请问各位有遇到过嘛,或者知道问题大概出在哪里的
    4 replies  •  2015-11-25 22:44:36 +08:00
    knightdf
        2
    knightdf  
       Nov 25, 2015
    建议你参考 RFPDupefilter 的源码写,然后这个 filter 会被 Scheduler 自动调用 from_settings 函数初始化,源码里都有
    knightdf
        3
    knightdf  
       Nov 25, 2015
    然后你的错误应该是没有实现 filter 的 classmethod from_settings ,这个是 scheduler 会自动调用的,必须有的
    nexus6
        4
    nexus6  
    OP
       Nov 25, 2015
    @tongle 多谢回复,回头到公司再研究研究
    @knightdf 多谢,我会试试的,话说 classmethod 是可以继承的吧,继承自 RFDupefilter 的类应该是有这个方法的呀?
    纯粹问问,具体结果试过了再说
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   803 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:30 · PVG 06:30 · LAX 15:30 · JFK 18:30
    ♥ Do have faith in what you're doing.