The ghost is not working

I am trying to use the example code from its own site and it does not work at all:

from ghost import Ghost
ghost = Ghost()

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

This is a pretty simple example, and this is a trace:

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

I am working with Python 2.7, I have already installed PySide 1.2.4 for 64 bit and I am working on a machine with Windows7

EDIT:

I 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 now the trace:

AttributeError: the object "NoneType" does not have the attribute "http_status", but if I use the same code without

print the .http_status page

No error displayed

EDIT2:

Martijn Pieters gives 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 is of type "none"

+4
source share
1 answer
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')
~                                         

~

0
source

Source: https://habr.com/ru/post/1663210/


All Articles