You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/Ayms/node-googleSearch.git
cd node-googleSearch
npm link .
Use :
googlesearch.js :
As a module :
var googleSearch = require('node-googleSearch').googleSearch;
var $E=encodeURIComponent;
var response={
end:function(result) {
console.log(result);
//output format, see below
}
};
var params='search='+$E('nikestore nike shoe')'+'&name='+$E(nike_shoes);
googleSearch(params,response);
As a server or an API :
var http = require('http'),
URL = require('url'),
googleSearch= require('node-googleSearch').googleSearch;
var handleRequest = function (request, response) {
var qs = URL.parse(request.url);
if (qs.pathname == '/googlesearch'){
googleSearch(qs.query,response);
};
};
http.createServer(handleRequest).listen(myport);
var xscript=document.createElement('SCRIPT');
xscript.type="text/javascript";
var params='name=nike_shoes'+'&search='+$E(nikestore nike shoe);
xscript.src='https://myserver:myport/googlesearch?'+params;
document.head.appendChild(xscript);
xscript.onload or onreadystatechange --> do what you have to do with the output
Output format (see more details below) : nike_shoes=(Google Search result) (where 'nike_shoes' corresponds to the parameter 'name')
Example : xscript.onload=function() {alert(nike_shoes)};
Parameters :
name : the name that will become the name of the global var containing the result (example : nike_shoes).