-1

I'm trying to scrape a page http://www.buddytv.com/trivia/game-of-thrones-trivia.aspx with Phantom.JS

Here's the code:

 search = page.evaluate(function() { 
     return  '<div class="question">' + $('#id60questionText').text() +  '</div>';
 });
 results = page.evaluate(function() { 
     return  $('#id78questionRegion').html();
 });
 answer = page.evaluate(function() { 
      $('a[href="javascript:___gid_10(0)"]').trigger("click");
     return  $('body').html();
 });

The first two part run without issues, but the last one doesn't. Basically, I want to click on the first answer and return the content of the page that appears once that's been done (and select the answer, but it goes too quickly on the website and I can't check which selector it's in). Anyways, the html returned does not contain the answer and I'm guessing I'm not triggering the click properly. Any advice ?

Thanks a lot, you're all great,

Callombert
  • 1,099
  • 14
  • 38

1 Answers1

0

If you look at the jQuery source for trigger, you see

elem[type]();

but unfortunately HTMLElement.click is non-standard and not available in PhantomJS. Just one more reason not to use jQuery. See PhantomJS; click an element.

Didn't PhantomJS print an error message? I would have expected to see something like elem.click is not a function. Otherwise, you can try wrapping this in a try/catch block and console.out'ing the error. If that still doesn't solve your problem, you can debug remotely; google for "phantomjs remote debugging".

Community
  • 1
  • 1