By default, it gives 10 results. How can I have n
number of results?
Here is my code so far (pretty much same as in their example):
var google = require('googleapis');
var customsearch = google.customsearch('v1');
const CX = '***'; // search engine ID
const API_KEY = '***';
const SEARCH = '***';
customsearch.cse.list({ cx: CX, q: SEARCH, auth: API_KEY }, function(err, resp) {
if (err) {
console.log('An error occured', err);
return;
}
// Got the response from custom search
console.log('Result: ' + resp.searchInformation.formattedTotalResults);
if (resp.items && resp.items.length > 0) {
var l = resp.items.length;
console.log('# of results: ' + l); // this is always 10
console.log('Results:', resp.items);
for(var i=0; i<l; i++){
console.log('Result # ' + (i+1) + ': ', resp.items[i]);
}
}
});
UPDATE: What if I want to access 238 results? I know that I can loop through and get 10 results each time, but it doesnt allow me to go past 99 results.