I'm using node.io to scrape websites. Currently I'm going through the scraping tutorial.
I'm using each with a selector
$('selector').each( ... , function () { ... } );
However when the selector selects only one element, I am receiving this problem:
TypeError: Object #<Object> has no method 'each'
What might be a cause for this, and how can I mitigate this issue
After looking at
node.io's source code, it appears that by default it usesnode-soupselectand not jQuery.Try setting:
inside your job's run method. Alternatively, when you create the job, set it
This is checked by these lines in the code, and it will enforce the correct behavior.
From
node.io's creator chriso:See this project issue on how you could change it to use
jQueryinstead which will solve your issue, along with workarounds and benefits of sticking tosoupselect.According to your link, when you're using
$you're not using jQuery, you're using node-soupselect.It does not have a
.eachmethod.Instead use
Which is a native JS function