Ghost.py icon indicating copy to clipboard operation
Ghost.py copied to clipboard

Ghost behaving differently from a browser when opening a page

Open Darayavaush opened this issue 9 years ago • 0 comments

I have the following code (latest version of Ghost, running Pyside):

from ghost import Ghost
headers = {
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Accept-Language':'en-US,en;q=0.8',
    'Connection':'keep-alive',
    'Host':'soundcloud.com',
    'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36'
}
url2 = 'https://soundcloud.com'
ghost = Ghost().start()
ghost.open(url2, headers=headers)
open('temp.html', encoding="utf-8", mode="w").write(ghost.content)

The headers were copied from Chrome (though nothing changes when they aren't included). When running this code, I get the following warnings:

   2015-07-27T13:04:44.731Z [WARNING ] QT: QFont::setPixelSize: Pixel size <= 0 (0)
   2015-07-27T13:04:46.244Z [WARNING ] Ghost<39208ab6-f7e8-48d2-a69d-a7a46979cf47>: undefined(0): TypeError: 'undefined' is not a function

And the resulting temp.html contains an error from the site (with fully formed interface) saying 'we cannot find this page' (not just a 404 error). According to https://github.com/jeanphix/Ghost.py/issues/112 the second warning is caused by javascript on the page failing to work correctly, but I'm not seeing this error in Chrome error console. Needless to say, loading the front page works from an actual browser.

Darayavaush avatar Jul 27 '15 10:07 Darayavaush