简体   繁体   中英

Ghost doesn't work

I'm trying to use the example code from his own website and it does not work at all:

from ghost import Ghost
ghost = Ghost()

page, resources = ghost.open('http://google.com')

It's a quite simple example and this is the traceback :

AttributeError: 'Ghost' object has no attribute 'open'

I'm working with Python 2.7, I have already installed PySide 1.2.4 for 64bits and I'm working in a machine with Windows7

EDIT:

I have tried this :

import ghost
g = ghost.Ghost()
with g.start() as session:
     page, extra_resources = session.open("http://www.google.es")
     print page.http_status

And the traceback now is :

AttributeError: 'NoneType' object has no attribute 'http_status' but if I use the same code without the

print page.http_status

It shows no error

EDIT2:

Martijn Pieters give me this possible solution :

from ghost import Ghost, Session

ghost = Ghost()

ghost = Session(ghost)

ghost.open('http://www.google.com')

ghost.capture_to('screen_shot.png')

This code works but the screenshot is empty and the object has a 'none' type

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')
~                                         

~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM