默认情况下,它会给出 10 个结果。我怎样才能有n
结果?
到目前为止,这是我的代码(与他们的示例几乎相同):
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]);
}
}
});
更新: 如果我想访问 238 个结果怎么办?我知道我每次可以循环并获得 10 个结果,但它不允许我超过 99 个结果。