human
I am working on the file "Scrapy_nb/CPL notebook.ipynb".
The first task is:
set up pipeline
This class creates a simple pipeline that writes all found items to a JSON file, where each line contains one JSON element.
Can you write Python code for it?
 What is a the Python code you requested?
assistant
#Here is the Python code you requested.

class JsonWriterPipeline(object):

    def open_spider(self, spider):
        self.file = open('cplresult.jl', '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