i'm using this snippet to implement a custom searh engine:
var google = require('googleapis');
var customsearch = google.customsearch('v1');
const CX = 'myCXKey';
const API_KEY = 'myApiKey';
const SEARCH = 'stackoverflow';
customsearch.cse.list({ cx: CX, q: SEARCH, auth: API_KEY }, function (err, resp) {
if (err) {
return console.log('An error occured', err);
}
// Got the response from custom search
//console.log('Result: ' + resp.searchInformation.formattedTotalResults);
if (resp.items && resp.items.length > 0) {
console.log(resp.items[0]);
}
});
with stackoverflow as research field i'm getting this:
{ kind: 'customsearch#result',
title: 'Brevetto USD769288 - Display screen with an animated graphical ...',
htmlTitle: 'Brevetto USD769288 - Display screen with an animated graphical ...',
link: 'https://www.google.it/patents/USD769288',
displayLink: 'www.google.it',
snippet: 'Available online at URL: <http://stackoverflow.com/questions/3377254/autogroup\n-uitableview-alphabetically>. 5, *, Rezgui, Neji. "Indexable ListView sur Android ...',
htmlSnippet: 'Available online at URL: <http://<b>stackoverflow</b>.com/questions/3377254/autogroup<br>\n-uitableview-alphabetically>. 5, *, Rezgui, Neji. "Indexable ListView sur Android ...',
cacheId: 'GieXn_KFPMAJ',
formattedUrl: 'https://www.google.it/patents/USD769288',
htmlFormattedUrl: 'https://www.google.it/patents/USD769288',
pagemap:
{ book: [ [Object] ],
metatags: [ [Object] ],
cse_image: [ [Object] ] } }
what i want to achieve is to retrieve only the first result of google search. is it possible to do that?
for example:
for stackoverflow search i want to be displayed the correspondent URL.
thanks in advance.
via OiRc
No comments:
Post a Comment