1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # -*- 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
- import requests
- import datetime
- class AirHistoryPipeline(object):
- def open_spider(self, spider):
- self.file = open('area.json', 'w')
- def process_item(self, item, spider):
- context = json.dumps(dict(item),ensure_ascii=False) + '\n'
- self.file.write(context)
- return item
- def close_spider(self,spider):
- self.file.close()
- class ManhuaPipeline(object):
- def process_item(self, item, spider):
- return item
- #
- class mmonlyPipeline(object):
- def process_item(self, item, spider):
- count = 0
- detailURL = item['detailURL']
- fileName = item['fileName']
- # print('5555555',detailURL)
- # print( fileName)
- image = requests.get(detailURL)
- # print('777777',image)
- f= open(fileName, 'wb')
- f.write(image.content)
- f.close()
- return item
|