Scrapy爬虫无法保存数据到csv文件

问题遇到的现象和发生背景

我使用scrapy框架爬取东方财富股吧发帖信息,想要将数据存入CSV文件。Scrapy程序能正常运行,但是运行结束后在指定文件夹找不到保存数据的文件。以下是Pipelines.py文件中的代码。请大神帮忙看看pipelines.py里面的程序有没有什么错误。

问题相关代码,请勿粘贴截图
import csv
import os
from eastmoney.items import PostItem

class EastmoneyPipeline(object):
    def process_item(self, item, spider):
        base_dir = 'D:'+ os.sep + '情绪因子项目' + os.sep + '结果文件'
        if not os.path.isdir(base_dir):
            os.makedirs(base_dir)
        file_path = base_dir + os.sep + item['stock_id'] + '.csv'
        if not os.path.isfile(file_path):
            is_first_write = 1
        else:
            is_first_write = 0
        if type(item) is PostItem:
            with open(file_path, 'a', encoding='utf_8_sig', newline='') as f:
                writer = csv.writer(f)
                if is_first_write:
                    header = [
                        'stock_id', 'url', 'username', 'title', 'content', 'created_time',
                        'updated_time', 'read_count', 'comment_count', 
                    ]
                    writer.writerow(header)
                writer.writerow(
                    [item['stock_id'],item['url'],item['username'],item['title'],item['content'],item['created_time'],
                     item['updated_time'],item['read_count'],item['comment_count']])
        return item

运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

我测试代码没有问题, 你程序正常运行没有报错吗?
你item参数是否传递正确,是PostItem类的实例对象吗
if type(item) is PostItem: 改成 if isinstance(item, PostItem):试试

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img