# -*- coding: utf-8 -*- import logging from database.models import Neodarznet class NeodarznetPipeline(object): def process_item(self, item, spider): try: page = Neodarznet.get(Neodarznet.url == item['url']) if page.content_length != item['content_length']: q = Neodarznet.update(**item).where(Neodarznet.url == item['url']) q.execute() logging.info("Update item {}".format(page)) except Neodarznet.DoesNotExist: page = Neodarznet.create(**item) logging.info("Create item {}".format(page)) logging.info('Item {} stored in db'.format(page)) return item