Search code examples
javascriptpythonghost.py

Ghost.py links through javascript


I'm having an issue with Ghost.py. The site I am trying to crawl has links for a paginated list that work with javascript, rather than direct hrefs. When I click the links, I can't really wait for selectors because the selectors are the same on each page, so ghost doesn't wait since the selector is already present. I can't assume I know what text will be on the next page, so waiting for text will not work. And waiting for page loaded won't work either. It's almost as though the javascript is not being executed.

Ghost.py seems to have minimal documentation (if you can call the examples on the website documentation) so it is really difficult to work out what I can do, and what tools are available to me. Can anybody with more experience help me out?


Solution

  • I solved my problem. There is an optional parameter to the Ghost class' click() method called expect_loading and when set to true it sets an internal boolean self.loaded = False and then calls wait_for_page_loaded() which then works, I guess because of the loaded boolean.