blob: 6703796bec4d13a0eb664b6b9b50e037265b4a70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# -*- coding: utf-8 -*-
import logging
from database.models import Page
class NeodarznetPipeline(object):
def process_item(self, item, spider):
try:
page = Page.get(Page.url == item['url'])
q = Page.update(**item).where(Page.url == item['url'])
q.execute()
logging.info("Update item {}".format(page))
except Page.DoesNotExist:
page = Page.create(**item)
logging.info("Create item {}".format(page))
logging.info('Item {} stored in db'.format(page))
return item
|