scrapy 存储excel文件
from openpyxl import Workbook class FangyuanPipeline(object): def __init__(self): self.wb = Workbook() self.ws = self.wb.active self.ws.append(['姓名', '电话']) def process_item(self, item, spider): # 工序具体内容 line = [item['name'], item['phone']] # 把数据中每一项整理出来 self.ws.append(line) # 将数据以行的形式添加到xlsx中 self.wb.save('info.xlsx') return item