异常.类型错误:\uU init_Uu()只接受1个参数(给定3个)

2024-10-16 17:24:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我通过继承RFPDupeFilter创建一个自定义过滤器。 下面是我使用代码的链接: https://github.com/j4s0nh4ck/wiki-spider/blob/master/wiki/wiki/SeenURLFilter.py

注意:我在一个名为custom的自定义文件中有上述代码_过滤器.py在同一目录中设置.py居住在设置.py我有这个密码。在

DUPEFILTER_CLASS = 'myspider.custom_filters.SeenURLFilter'

但是当我运行机器人时,我得到了一个错误:

exceptions.TypeError: __init__() takes exactly 1 argument (3 given)


Tags: 代码pyhttpsgithubmastercom过滤器链接
1条回答
网友
1楼 · 发布于 2024-10-16 17:24:27

正如您在回溯中看到的那样,from_settings()方法被调用-然后它会创建一个自定义dupe过滤器的实例。但是,由于您没有指定您自己的from_settings()方法the one from built-in ^{} is used

@classmethod
def from_settings(cls, settings):
    debug = settings.getbool('DUPEFILTER_DEBUG')
    return cls(job_dir(settings), debug)

它尝试使用pathdebug构造函数参数实例化自定义dupe筛选器。并且您的SeenURLFilter构造函数不接受debug参数。在

您还需要让dupefilter接受^{} parameter

^{pr2}$

相关问题 更多 >