Scrapy throws ImportError: cannot import name xmlrpc_client

I’ve just fixed this issue on my OS X. Please backup your files first. sudo rm -rf /Library/Python/2.7/site-packages/six* sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six* sudo pip install six Scrapy 1.0.0 is ready to go. If you encounter an error rm: /System/Library/… Operation not permitted Please try to disable System Integrity Protection See Operation Not Permitted when on … Read more

CrawlerProcess vs CrawlerRunner

Scrapy’s documentation does a pretty bad job at giving examples on real applications of both. CrawlerProcess assumes that scrapy is the only thing that is going to use twisted’s reactor. If you are using threads in python to run other code this isn’t always true. Let’s take this as an example. from scrapy.crawler import CrawlerProcess … Read more

Force my scrapy spider to stop crawling

In the latest version of Scrapy, available on GitHub, you can raise a CloseSpider exception to manually close a spider. In the 0.14 release note doc is mentioned: “Added CloseSpider exception to manually close spiders (r2691)” Example as per the docs: def parse_page(self, response): if ‘Bandwidth exceeded’ in response.body: raise CloseSpider(‘bandwidth_exceeded’) See also: http://readthedocs.org/docs/scrapy/en/latest/topics/exceptions.html?highlight=closeSpider

Access Django models with scrapy: defining path to Django project

I think the main misconception is the package path vs the settings module path. In order to use django’s models from an external script you need to set the DJANGO_SETTINGS_MODULE. Then, this module has to be importable (i.e. if the settings path is myproject.settings, then the statement from myproject import settings should work in a … Read more