V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2015-11-25 18:38:05 +08:00 · 2236 次点击
    这是一个创建于 3065 天前的主题,其中的信息可能已经有所发展或是发生改变。
    自己实现了一个过滤器方法 custom_filter , settings 中设置
    DUPEFILTER_CLASS = 'crawls.spiders.custom_filter'

    运行项目时提示'module' object has no attribute 'from_settings'
    请问各位有遇到过嘛,或者知道问题大概出在哪里的
    4 条回复    2015-11-25 22:44:36 +08:00
    tongle
        1
    tongle  
       2015-11-25 19:08:24 +08:00   ❤️ 1
    knightdf
        2
    knightdf  
       2015-11-25 21:37:58 +08:00
    建议你参考 RFPDupefilter 的源码写,然后这个 filter 会被 Scheduler 自动调用 from_settings 函数初始化,源码里都有
    knightdf
        3
    knightdf  
       2015-11-25 21:42:03 +08:00
    然后你的错误应该是没有实现 filter 的 classmethod from_settings ,这个是 scheduler 会自动调用的,必须有的
    nexus6
        4
    nexus6  
    OP
       2015-11-25 22:44:36 +08:00
    @tongle 多谢回复,回头到公司再研究研究
    @knightdf 多谢,我会试试的,话说 classmethod 是可以继承的吧,继承自 RFDupefilter 的类应该是有这个方法的呀?
    纯粹问问,具体结果试过了再说
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1304 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.