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

Cannot use 'in' operator to search for 'jquery' in undefined #126

Closed
HolaMan opened this issue Nov 14, 2014 · 3 comments
Closed

Cannot use 'in' operator to search for 'jquery' in undefined #126

HolaMan opened this issue Nov 14, 2014 · 3 comments

Comments

@HolaMan
Copy link

HolaMan commented Nov 14, 2014

I just use the sample code

var Crawler = require("crawler");
var url = require('url');

var c = new Crawler({
    maxConnections : 10,
    jQuery: 'cheerio',
    // This will be called for each crawled page
    callback : function (error, result, $) {
        // $ is Cheerio by default
        //a lean implementation of core jQuery designed specifically for the server
        $('a').each(function(index, a) {
            var toQueueUrl = $(a).attr('href');
            c.queue(toQueueUrl);
        });
    }
});

// Queue just one URL, with default callback
c.queue('https://news.ycombinator.com/');

and get the error while running

C:\Users\User\Desktop\crawler\node_modules\crawler\lib\crawler.js:34
if ('jquery' in options) {
^
TypeError: Cannot use 'in' operator to search for 'jquery' in undefined
at checkJQueryNaming (C:\Users\User\Desktop\crawler\node_modules\crawler\lib
\crawler.js:34:21)
at Crawler._pushToQueue (C:\Users\User\Desktop\crawler\node_modules\crawler
lib\crawler.js:210:15)
at Crawler.queue (C:\Users\User\Desktop\crawler\node_modules\crawler\lib\cra
wler.js:201:14)
at Object. (C:\Users\User\Desktop\crawler\app.js:13:15)
at exports.each (C:\Users\User\Desktop\crawler\node_modules\crawler\node_mod
ules\cheerio\lib\api\traversing.js:294:24)
at Object.Crawler.callback (C:\Users\User\Desktop\crawler\app.js:11:16)
at Crawler._onInject (C:\Users\User\Desktop\crawler\node_modules\crawler\lib
\crawler.js:473:13)
at C:\Users\User\Desktop\crawler\node_modules\crawler\lib\crawler.js:462:18
at Crawler._inject (C:\Users\User\Desktop\crawler\node_modules\crawler\lib\c
rawler.js:147:9)
at Crawler._onContent (C:\Users\User\Desktop\crawler\node_modules\crawler\li
b\crawler.js:461:14)

I am using Windows 8 with node version 0.10.32

@ghost
Copy link

ghost commented Nov 14, 2014

Thanks, im having a look now. I was able to reproduce it, and will write a fix soon.

@ghost
Copy link

ghost commented Nov 14, 2014

The problem is, at some point, you try to crawl an url with the value: undefined

c.queue(toQueueUrl);  //toQueueUrl is undefined

I'm writing a test, and a fix to skip this kind of obvious problem.

@ghost
Copy link

ghost commented Nov 14, 2014

Fix in 0.4.1

@ghost ghost closed this as completed Nov 14, 2014
jasondeveloper-1099 added a commit to jasondeveloper-1099/Node-Crawler that referenced this issue May 20, 2022
This issue was closed.
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

1 participant