【发布时间】:2011-02-15 14:13:24
【问题描述】:
我是 python 新手,今天才下载它。我正在使用它来处理网络蜘蛛,所以为了测试它并确保一切正常,我下载了一个示例代码。不幸的是,它不起作用并给我错误:
"AttributeError: 'MyShell' 对象没有属性'loaded'"
我不确定代码本身是否有错误,或者我在安装 python 时未能正确执行某些操作。安装python时有什么需要做的吗,比如添加环境变量等等?该错误通常是什么意思?
这是我在导入的蜘蛛类中使用的示例代码:
import chilkat
spider = chilkat.CkSpider()
spider.Initialize("www.chilkatsoft.com")
spider.AddUnspidered("http://www.chilkatsoft.com/")
for i in range(0,10):
success = spider.CrawlNext()
if (success == True):
print spider.lastUrl()
else:
if (spider.get_NumUnspidered() == 0):
print "No more URLs to spider"
else:
print spider.lastErrorText()
# Sleep 1 second before spidering the next URL.
spider.SleepMs(1000)
【问题讨论】:
-
当 Python 抛出异常时,它会打印详细的堆栈跟踪。尝试在你的问题中加入这一点,它会给人们更多的继续。
-
错误信息大概有很多更多的信息。给出的内容不足以帮助您,但由于您给出的内容中似乎没有“MyShell”对象,因此问题出在其他地方。也许您没有正确安装软件,或者它具有尚未满足的依赖关系。根据提供的信息无法确定。
标签: python web-crawler attributeerror chilkat