2012-09-14 39 views
0

$ scrapy版本:0.14 $導入錯誤:無法導入擴展名

$文件:settings.py $

EXTENSIONS = { 'myproject.extensions.MySQLManager': 500 } 

$文件:pipeline.py $

# -- coding: utf-8 -- 
# Define your item pipelines here # 
# Don't forget to add your pipeline to the ITEM_PIPELINES setting 
# See: doc.scrapy.org/topics/item-pipeline.html 

from scrapy.project import extensions 
from urlparse import urlparse 
import re 
class MySQLStorePipeline(object): 
    def process_item(self, item, spider): 
     if self.is_allowed_domain(item['url'], spider) is True: 
      MySQLManager.cursor... #cannot load MySQLManager 

導入錯誤:不能導入擴展名。 我找不到擴展類/scrapy/project.py

回答

0

我不知道你想要導入什麼,但據我瞭解,如果你想「導入」一個擴展名,你應該添加一些行在你的scrapy項目中的settings.py文件中。

例子:

EXTENSIONS = { 
    'scrapy.contrib.corestats.CoreStats': 500, 
    'scrapy.webservice.WebService': 500, 
    'scrapy.myextension.myextension': 500, 
} 

你可以閱讀更多關於Scrapy擴展here

+0

請編輯您的意見,這樣我可以更好地閱讀它。 – Haldir87

相關問題