Node.js で使用する Google 検索 API ラッパーを探しています。検索しましたが、更新されて完全に焼き付けられたものは見つかりませんでした。誰かが何かをお勧めできますか?ありがとう
5 に答える
Google APIにノードクライアントライブラリを使用しないのはなぜですか?https://github.com/google/google-api-nodejs-client
var googleapis = require('googleapis');
googleapis.discover('customsearch', 'v1').execute(function(err, client) {
// set api key
client.withApiKey('...');
client.search.cse.list({ q: '...' }).execute(console.log);
});
node-google-images を使用したところ、2 分もかからずにすぐに機能しました。
https://github.com/vdemedes/node-google-images
電話するだけ
npm install google-images
その後
client = require( 'google-images' );
client.search( 'Chicken Teriyaki', function (err, images) {
console.log(images)
});
戻ります
[ { width: '1920', height: '1280', url: ' http://www.springkitchenrestaurant.com/Chicken_Teriyaki.jpg ', writeTo: [関数] }]
(実際には、4 つの結果が返されますが、stackoverflow により、2 つ以上のリンクを投稿できなくなります... -要点がわかります!)
非推奨の Google Web Search API について言及しているのではないと思います...
Google Custom Search APIはRESTful API です。これは、特別なラッパーなしで簡単にアクセスできることを意味します。
これを簡単にするモジュールがいくつかあります。私が通常使用するのはrequestモジュールです。これを使用すると、HTTP リクエストを非常に簡単に作成できます。
jsearch モジュールを使用できます。インストール:
npm install jsearch
使用法:
js.google('queryStringYouWant',10,function(response){
console.log(response) // for Google results
})