pipelines.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:scrapy_projects 作者: morefreeze 项目源码 文件源码
def process_item(self, item, spider):
        """return ip is duplicate or not

        :item: crawl item including host port
        :returns: return item or DropItem
        """
        if 'ip' not in item:
            raise DropItem('')
        port = item.get('port', 80)
        host = '%s:%s' % (item['ip'], port)
        if self.conn.sismember(settings.HOST_S, host) or self.dup_in_queue(host):
            raise DropItem('%s, cause duplicate' % (host))
        else:
            return item
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号