Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble loading jQuery into Google #9

Closed
neopunisher opened this issue Jul 20, 2011 · 2 comments
Closed

Trouble loading jQuery into Google #9

neopunisher opened this issue Jul 20, 2011 · 2 comments

Comments

@neopunisher
Copy link

heres the code im using to test...

var spider = require('spider');
var s = spider();
s.log('debug');
s.route('www.google.com', '/search*', function (window, $) {

console.log($(window.document.body).text());
});
s.get('http://www.google.com/search?q=carter');

the error seems to occur in the jqueryify function... the first line to get context fails... im not really sure how any of this works but it dies on
Script.runInContext(jquery, ctx, filename);

then the document object is null and it tries to call trigger() which doesnt exist

this is the error:
document.trigger(
^
TypeError: Object [ null ] has no method 'trigger'
at /home/ccole/node/spyder/node_modules/spider/main.js:60:16
at Spider._handler (/home/ccole/node/spyder/node_modules/spider/main.js:189:5)
at [object Object].callback (/home/ccole/node/spyder/node_modules/spider/main.js:164:12)
at [object Object]. (/home/ccole/node/spyder/node_modules/request/main.js:273:21)
at [object Object].emit (events.js:64:17)
at IncomingMessage. (/home/ccole/node/spyder/node_modules/request/main.js:261:54)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.onend (http.js:1265:12)
at Socket._onReadable (net.js:659:26)
at IOWatcher.onReadable as callback

@neopunisher
Copy link
Author

I think this issue is tied to the way jsdom uses javascript vm to run in context nodejs/node-v0.x-archive#1105

after making some modifications to spiders main.js to try and use the jsdom's jquerify i get

/home/ccole/node/spyder/rank-apis/google/spider/jsdom/lib/jsdom.js:162
window.document.body.appendChild(jQueryTag);
^
TypeError: Cannot call method 'appendChild' of null
at Object.jQueryify (/home/ccole/node/spyder/rank-apis/google/spider/jsdom/lib/jsdom.js:162:24)
at /home/ccole/node/spyder/rank-apis/google/spider/main.js:50:14
at Spider._handler (/home/ccole/node/spyder/rank-apis/google/spider/main.js:206:14)

that led me to find that the window and document objects look ok but there is no document.body not sure why...

@vieiralucas
Copy link
Collaborator

I'm pretty sure this is too old to keep opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants