Skip to content Skip to sidebar Skip to footer

Scrapy And Python. Nameerror

I'm trying to scrape the current currency exchange rates. Please could you take a look and see if you spot an error. items.py import scrapy class CurrItem(scrapy.Item): country

Solution 1:

You should place the right pipline class name here:

ITEM_PIPELINES = ['currency.pipelines.MongoDBPipeline', ]

change it to:

ITEM_PIPELINES = ['currency.pipelines.CurrencyPipeline', ]

Solution 2:

So, from the error:

exceptions.NameError: Module 'currency.pipelines' doesn't define any object named 'MongoDBPipeline'

It looks like scrapy needs some help actually articulating with Mongo. You can see that in your config file you have the following line:

ITEM_PIPELINES = ['currency.pipelines.MongoDBPipeline', ]

It appears that you don't actually have that item pipeline defined. Based on what you have above, renaming CurrencyPipeline as MongoDBPipeline should fix your problem.

Also, though this won't break your program, you shouldn't be using scrapy.log. Python has some excellent builtin logging functionality with documentation here. If it's been deprecated I wouldn't advise using it.

Post a Comment for "Scrapy And Python. Nameerror"