Scrapy ImportError:无法导入名称扩展名
$scrapy版本:0.14$ $file:settings.py$Scrapy ImportError:无法导入名称扩展名,scrapy,Scrapy,$scrapy版本:0.14$ $file:settings.py$ EXTENSIONS = { 'myproject.extensions.MySQLManager': 500 } $file:pipeline.py$ # -- coding: utf-8 -- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: do
EXTENSIONS = { 'myproject.extensions.MySQLManager': 500 }
$file: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
ImportError:无法导入名称扩展名。
我在/scrapy/project.py中找不到extensions类我不知道您要导入什么,但据我所知,如果您想“导入”扩展名,您应该在scrapy项目的settings.py文件中添加一些行 例如:
EXTENSIONS = {
'scrapy.contrib.corestats.CoreStats': 500,
'scrapy.webservice.WebService': 500,
'scrapy.myextension.myextension': 500,
}
您可以阅读有关Scrapy扩展的更多信息