fix JsonWriterPipeline example

This commit is contained in:
Bernardas 2016-10-03 20:31:41 +00:00
parent 3235bfeb1e
commit eb91cb8ea2
1 changed files with 4 additions and 1 deletions

View File

@ -106,9 +106,12 @@ format::
class JsonWriterPipeline(object):
def __init__(self):
def open_spider(self, spider):
self.file = open('items.jl', 'wb')
def close_spider(self, spider):
self.file.close()
def process_item(self, item, spider):
line = json.dumps(dict(item)) + "\n"
self.file.write(line)