Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

fix JsonWriterPipeline example

Bernardaseb91cb8ea2c0
diff --git a/docs/topics/item-pipeline.rst b/docs/topics/item-pipeline.rst
index 6b43fe258..11b56f1c4 100644
--- a/docs/topics/item-pipeline.rst
+++ b/docs/topics/item-pipeline.rst
@@ -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)