1

Using scrapy version 0.16. Trying to create a standalone spider runnable from a script as per this gist. Importing the above generates this:

    Traceback (most recent call last):
  File "./spiderctl.py", line 8, in <module>
    from scrapy.conf import settings
  File "/usr/local/lib/python2.6/dist-packages/scrapy/conf.py", line 4, in <module>
    from scrapy.project import crawler
ImportError: cannot import name crawler

The file conf.py contains the line:

from scrapy.project import crawler

But the file scrapy.project is only a comment that the module is deprecated and users should instead implement the from_crawler class method. How do I implement this in the context of the code above?

4

2 回答 2

1

您可以在这个新的常见问题解答中找到这个问题的答案:

基本上,您需要以不同的方式访问爬虫,使用from_crawler类方法而不是crawlerscrapy.project.

于 2013-03-14T16:08:55.610 回答
1

我认为您是旧版本的scrapy闲逛,因为最新版本没有您提到的那一行:

https://github.com/scrapy/scrapy/blob/master/scrapy/conf.py

更新:

好吧,它就在那里:https ://github.com/scrapy/scrapy/commit/e8e5a62c20b3d217cc55038f30e495ca183bbba7#L1R0

尝试安装最新版本,看看它是否有效:

python setup.py install
于 2012-11-02T19:35:26.163 回答