Reputation: 95
I'm using NodeJS and I'm trying to perform a Google search.
I'm using the google package. Here is my code:
const google = require('google');
google.resultsPerPage = 25;
google('wikipedia', function (err, res) {
if (err) console.log(err);
});
console.log(res.links);
});
And res.links
is an empty array. I made the search manually, with the exact link used by the node app (which is https://www.google.com/search?hl=en&q=wikipedia&start=0&sa=N&num=25&ie=UTF-8&oe=UTF-8&gws_rd=ssl), and I get results.
Do you have any idea why it's not returning anything?
Upvotes: 0
Views: 457
Reputation: 4122
First You have a syntax error
It should be
const google = require('google');
google.resultsPerPage = 25;
google('wikipedia', function (err, res) {
if (err) console.log(err);
else {
console.log(res.links);
}
});
Second, if you check the package's Github page, it seems that the it does not work anymore https://github.com/jprichardson/node-google/issues/65 and they are suggesting using https://www.npmjs.com/package/google-it instead.
Upvotes: 1