用于Node.js的GooglesearchAPI包装器

我正在寻找一个谷歌searchAPI包装在Node.js中使用,我已经四处search,但还没有find更新和完全烘焙的东西。 任何人都可以请推荐一些工作? 谢谢

你为什么不使用节点客户端库的谷歌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); }); 

我假设你不是指不赞成的Google Web Search API …

Google自定义searchAPI是一个RESTful API。 这意味着您可以轻松访问它,而无需专门的包装。

有几个模块可以使这更容易。 我通常使用的是请求模块,它可以让你非常简单地进行HTTP请求。

我只是使用节点谷歌图像,并在不到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:[Function]}]

(实际上,它会返回4个结果,但stackoverflow阻止我发布超过2个链接… – 你得到的要点!)

你可以使用jsearch模块。 安装时使用:

 npm install jsearch 

用法:

 js.google('queryStringYouWant',10,function(response){ console.log(response) // for Google results })