aboutsummaryrefslogtreecommitdiff
path: root/myproject/myproject/pipelines.py
blob: 4cf9b9ed0d01a7b9ad5537f675bf76ec6e0b70c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- coding: utf-8 -*-
import json


class FileWritePipeline(object):

    def open_spider(self, spider):
        self.file = open('items.json', 'w')

    def close_spider(self, spider):
        self.file.close()

    def process_item(self, item, spider):
        line = json.dumps(dict(item)) + "\n"
        self.file.write(line)
        return item