python - scrapy 蜘蛛停在第一个重复的项目

标签 python python-2.7 scrapy

我在 python 2.7 中使用 scrapy 0.20

我想避免重复的项目。

我不想在命令行中使用 JOBDIR 作为参数。相反,我在我的脚本中这样做:

settings.overrides['JOBDIR']= 'my customer jobdir'

然后我在我的设置中这样做:

DUPEFILTER_CLASS = 'MyProject.CustomFilter.CustomFilter'

并且在 CustomFilter 中我起诉了这个:

def request_seen(self, request):
        fp = self.__getid(request.url)
        if (fp is not None) and (fp in self.fingerprints):
            return True
        elif fp is not None:
            self.fingerprints.add(fp)
            if self.file:
                self.file.write(fp + os.linesep)
        else:
            return False 

其中 __getid 是我使用的辅助函数。

我的问题

蜘蛛在找到第一个重复项时停止工作。

我在 CMD 上发现了这条消息:

2014-03-03 10:43:44-0800 [GeneralSpider] DEBUG: Filtered duplicate request: <GET
 http://www.justproperty.com/apartments/old-town/1057362-most-affordable-2-b-r-i
n-old-town-for-sale.html> - no more duplicates will be shown (see DUPEFILTER_CLA
SS)

最佳答案

您可以在请求调用中使用参数 dont_filter=True。这将指示 scrapy 不要忽略重复的请求。已记录 here

关于python - scrapy 蜘蛛停在第一个重复的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22154886/

相关文章:

python - 设置 tensorflow 舍入模式

python - 按住按钮和窗口更新问题

Python从列表中找到最接近的匹配项

python - 如何使用 xpath 排除某些元素?

Python 将行转换为数组

java - AES 加密结果不同 Java 和 Python

python - 我想知道当我们只想打印 pandas 中的特定列时如何实现

Python lambda函数计算数字的阶乘

python - Scrapy:使用正则表达式跟踪链接

python - Scrapy回调函数