【发布时间】:2016-12-08 09:03:37
【问题描述】:
我正在尝试使用他自己网站上的示例代码,但它根本不起作用:
from ghost import Ghost
ghost = Ghost()
page, resources = ghost.open('http://google.com')
这是一个非常简单的例子,这是回溯:
AttributeError: 'Ghost' object has no attribute 'open'
我正在使用 Python 2.7,我已经安装了 64 位的 PySide 1.2.4,并且正在使用 Windows7 的机器上工作
编辑:
我已经试过了:
import ghost
g = ghost.Ghost()
with g.start() as session:
page, extra_resources = session.open("http://www.google.es")
print page.http_status
现在的回溯是:
AttributeError: 'NoneType' 对象没有属性 'http_status' 但如果我使用相同的代码而没有
打印页面.http_status
没有错误
EDIT2:
Martijn Pieters 给了我这个可能的解决方案:
from ghost import Ghost, Session
ghost = Ghost()
ghost = Session(ghost)
ghost.open('http://www.google.com')
ghost.capture_to('screen_shot.png')
此代码有效,但屏幕截图为空且对象的类型为“无”
【问题讨论】:
-
有趣的是,我找不到
open()方法,看起来项目重构了但忘记更新快速入门。 -
另见github.com/jeanphix/Ghost.py/issues/304,他们的问题跟踪器中可能还有其他人。
-
我得到的是一个空的截图。我正在为“页面”对象获取“无”
标签: python python-2.7 ghost.py