'null' is not an object error when including jQuery into an opened page using PhantomJS -
i'm trying out phantomjs , wanted use extract content webpage. however, cannot inject jquery using following code.
console.log('ssl support = ', require('system').issslsupported); var page = require('webpage').create(); console.log('page created'); page.open('https://www.google.com/#q=my+test+query', function() { console.log('page opened'); page.includejs("http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js", function() { console.log('jquery injected'); phantom.exit(); }); });
when run code, see error
c:\users\royshi\skydrive\developer\crawler>phantomjs test.txt ssl support = true page created page opened typeerror: 'null' not object (evaluating 'document.body.appendchild') http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js:1 ^c c:\users\royshi\skydrive\developer\crawler>
my code not different the example provided phantomjs. wondering wrong here.
edit:
it seems there wrong url used in above example (i.e. "https://www.google.com/#q=my+test+query"). code works url: https://www.google.com/:
c:\users\royshi\skydrive\developer\crawler>phantomjs test.txt ssl support = true page created page opened jquery injected c:\users\royshi\skydrive\developer\crawler>
wondering what's wrong url "https://www.google.com/#q=my+test+query".
answering edit got solution: hashtag triggers redirect. don't know phantomjs suspect need follow manually this gist suggests.
Comments
Post a Comment