text: # -*- coding: utf-8 -*-
  
  # 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
  import json
  from datetime import date, datetime
  
  
  class ScrapyPoiPipeline(object):
      def __init__(self):
          self.file = open('qidoan.json', 'w', encoding='utf-8')
  
      def close_spider(self, spider):
          self.file.close()
  
      def process_item(self, item, spider):
          line = json.dumps(dict(item), ensure_ascii=False, cls=ComplexEncoder) + '\n'
          self.file.write(line)
          return item
  
  
  class ComplexEncoder(json.JSONEncoder):
      def default(self, obj):
          if isinstance(obj, datetime):
              return obj.strftime('%Y-%m-%d %H:%M:%S')
          elif isinstance(obj, date):
              return obj.strftime('%Y-%m-%d')
          else:
              return json.JSONEncoder.default(self, obj)
  