aboutsummaryrefslogtreecommitdiff
path: root/crawler/nevrax/pipelines.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crawler/nevrax/pipelines.py19
1 files changed, 19 insertions, 0 deletions
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