AttributeError: 'DoubanPipeline' object has no attribute 'post'
我和视频上的代码一样的...在pipelines.py添加mongo的配置后,怎么老是报这个错呢
我和视频上的代码一样的...在pipelines.py添加mongo的配置后,怎么老是报这个错呢
2018-09-11
2018-09-11 18:36:11 [scrapy.core.scraper] ERROR: Error processing {'describe': '我们都曾经是一一。',
'evaluate': '176905人评价',
'introduce': '2000/台湾日本/剧情爱情家庭',
'movie_name': '一一',
'serial_number': '100',
'star': '8.9'}
Traceback (most recent call last):
File "/usr/python/lib/python3.5/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/root/douban/douban/pipelines.py", line 22, in process_item
self.post.insert(data)
AttributeError: 'DoubanPipeline' object has no attribute 'post'这是完整的错误代码...下面是我的配置文件pipelines.py
# -*- coding: utf-8 -*- import pymongo from douban.settings import mongo_host,mongo_port,mongo_db_name,mongo_db_collection # 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 DoubanPipeline(object): def __int__(self): host = mongo_host port = mongo_port dbname = mongo_db_name sheetname = mongo_db_collection client = pymongo.MongoClient(host=host,port=port) mydb = client[dbname] self.post = mydb[sheetname] def process_item(self, item, spider): data = dict(item) self.post.insert(data) return item
举报