Ghost.py
Ghost.py copied to clipboard
Can't get wait_for_text to work when content loaded asynchronously
I am trying to get some date from the following site http://www.degreedaysforfree.co.uk/
first to have to click the login link to get a session cookie (No actual login needed) https://poweredby.stark.co.uk/SEO/DDFFLogin.aspx
Then select a site on the left and type of report and click download. In my script I just use the url that download redirects to. Ie https://poweredby.stark.co.uk/SEO/Output.aspx?RepNum=5512&RepRef=YRTS05%2FREPDD43%2F01%2FSEO%2FSQ&RepDate=27/2/2015&TZIndex=GMT%20Standard%20Time&DST=true&RepLen=1&GrpNum=4363&GrpRef=DD43%2FAAAK%2FAAAH%2F0001-0000100000%23DD43%2300000%23WUNDER&GrpsInSet=0
In chrome this all work the page you redirect to has some javascript to update the content so I do a wait_for_text but that call never waits.
My code is
from ghost import Ghost
signin_url = 'https://poweredby.stark.co.uk/SEO/DDFFLogin.aspx' download_url = 'https://poweredby.stark.co.uk/SEO/Output.aspx?RepNum=5512&RepRef=YRTS05%2FREPDD43%2F01%2FSEO%2FSQ&RepDate=27/2/2015&TZIndex=GMT%20Standard%20Time&DST=true&RepLen=1&GrpNum=4363&GrpRef=DD43%2FAAAK%2FAAAH%2F0001-0000100000%23DD43%2300000%23WUNDER&GrpsInSet=0'
ghost = Ghost(wait_timeout=500, display=True, javascript_enabled=True, log_level=logging.DEBUG) ghost.open(signin_url) ghost.wait_for_selector('button[id=runButton]')
ghost.open(download_url, wait=False) ghost.wait_for_text('CSV')
print ghost.content
Any ideas of the problem ?
Thanks for a great little library by the way. I have used it many times.