我试图使用他自己网站上的示例代码,它根本不起作用:
from ghost import Ghost
ghost = Ghost()
page, resources = ghost.open('http://google.com')这是一个非常简单的例子,这是一个跟踪:
AttributeError: 'Ghost' object has no attribute 'open'我正在使用Python2.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’,但是如果我使用相同的代码而不使用
打印page.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')此代码工作,但屏幕截图为空,该对象具有“none”类型。
发布于 2017-11-04 21:03:18
from ghost import Ghost
ghost = Ghost()
with ghost.start() as session:
page, extra_resources = session.open("http://www.google.de")
session.set_viewport_size(1920,1080)
session.capture_to('test.png')
~ ~
https://stackoverflow.com/questions/41035478
复制相似问题