python - 导入错误 : cannot import name ScrapyFileLogObserver

标签 python python-2.7 web-scraping scrapy

我尝试使用 ScrapyFileLogObserver 测试 scrapy 日志。在我的源代码中,我正确地设置了要使用的包:

from scrapy.log import ScrapyFileLogObserver

但是当我启动我的蜘蛛时出现了这个错误:

from scrapy.log import ScrapyFileLogObserver

ImportError: cannot import name ScrapyFileLogObserver

有关信息,我使用最新版本的 scrapy (Scrapy 1.0.1)。 我该如何修复我的错误?

最佳答案

在1.0 Scrapy的日志系统中was completely rewritten , 不再有 ScrapyFileLogObserver 了。相反,Scrapy 现在 uses twisted's PythonLoggingObserver directly :

observer = twisted_log.PythonLoggingObserver('twisted')
observer.start()

关于python - 导入错误 : cannot import name ScrapyFileLogObserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31837917/

相关文章:

python - OrderedDict 的设置、获取和 popitem 性能

python-2.7 - 如何在文本字段中设置字符限制..?

python - 带 python 的位串

java - 使用 Java 和 jsoup 进行网站抓取; html无法读取;空指针异常

python - 如何将非英文字符串存储到excel文件中,python3?

javascript - 使用 HTML5 <input> 字段抓取动态生成的网页

python - 在 Numpy 中创建 cos 和 sin 数组的最有效方法

python - 如何将 python 程序设置为 Windows 中的默认 Web 浏览器?

python - 如何使用 ENTER 输入打破循环

python - 这个 "score"到底是什么?使用 sklearn/Python 的额外树分类器