From a3f01580faf6caee4abcc8e682567b87380857b9 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 19 Jan 2019 00:02:57 +0100 Subject: Add khanindex nevrax indexation --- crawler/nevrax/pipelines.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 crawler/nevrax/pipelines.py (limited to 'crawler/nevrax/pipelines.py') diff --git a/crawler/nevrax/pipelines.py b/crawler/nevrax/pipelines.py new file mode 100644 index 0000000..775d5df --- /dev/null +++ b/crawler/nevrax/pipelines.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +import logging + +from database.models import Nevrax + + +class NevraxPipeline(object): + + def process_item(self, item, spider): + try: + page = Nevrax.get(Nevrax.url == item['url']) + q = Nevrax.update(**item).where(Nevrax.url == item['url']) + q.execute() + logging.info("Update item {}".format(page)) + except Nevrax.DoesNotExist: + page = Nevrax.create(**item) + logging.info("Create item {}".format(page)) + logging.info('Item {} stored in db'.format(page)) + return item -- cgit v1.2.1