使用Python的“Scrapy”错误
问题描述:
我在Python 2.7上安装了最新版本的Scrapy(是的,我仍然使用这个版本),并且在运行Scrapy的教程脚本时出现错误。 我跑的代码是:使用Python的“Scrapy”错误
from scrapy.spider import BaseSpider
class DmozSpider(BaseSpider):
name = "dmoz.org"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
"http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
]
def parse(self, response):
filename = response.url.split("/")[-2]
open(filename, 'wb').write(response.body)
的错误是:
Traceback (most recent call last):
File "C:/Users/Rainey/Desktop/dmoz/spiders/dmoz_spider.py", line 1, in <module>
from scrapy.spider import BaseSpider
File "C:\Python27\lib\site-packages\scrapy\spider.py", line 7, in <module>
from scrapy import log
File "C:\Python27\lib\site-packages\scrapy\log.py", line 10, in <module>
from twisted.python import log
ImportError: No module named twisted.python
教程脚本是我的桌面上。这种效果是否可以,我应该在不同的地方吗?
答
错误消息'ImportError:No module named twisted.python'表示您缺少twisted模块。
使用像pip或download a Windows binary这样的包管理器来安装扭曲。
Zope接口https://pypi.python.org/pypi/zope.interface#download – fedmich 2013-03-26 10:58:07