diff options
Diffstat (limited to 'myproject/myproject/pipelines.py')
-rw-r--r-- | myproject/myproject/pipelines.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/myproject/myproject/pipelines.py b/myproject/myproject/pipelines.py index 0bdee9f..4cf9b9e 100644 --- a/myproject/myproject/pipelines.py +++ b/myproject/myproject/pipelines.py @@ -1,11 +1,16 @@ # -*- coding: utf-8 -*- +import json -# Define your item pipelines here -# -# Don't forget to add your pipeline to the ITEM_PIPELINES setting -# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html +class FileWritePipeline(object): + + def open_spider(self, spider): + self.file = open('items.json', 'w') + + def close_spider(self, spider): + self.file.close() -class MyprojectPipeline(object): def process_item(self, item, spider): + line = json.dumps(dict(item)) + "\n" + self.file.write(line) return item |