Node Google Search Crawler
Node Google Search Crawler
Introduction
var g = require('node-g-search');
g.search("bon jovi")
.then(function(d){
if(d.data)
for (var i = 0; i < d.data.length; i++) {
console.log(d.data[i].title);
console.log(d.data[i].href);
console.log(d.data[i].des);
}
})
Installation
npm install --save node-g-search
Search API
g.search(q[,page[,retry]])
g.searchAll(q[,retry])
g.pg()
Connect to PostgreSQL
node-postgres built-in and complete access layer to node-postgres via Promises/A+.
var g = require('node-g-search'),
db = g.pg();
var p = db.connect({
user:'user',
password: 'pwd',
host: 'localhost',
dbname: 'dbname'
})
.then(function(client){
return db.query('select ?::int+?::int as ans',[10,20])
.then(function(res){
console.log(res.rows[0].ans);
return res.rows[0].ans;
},function(err){
console.log('%s',err);
})
})
Pg Client API
db.connect(option)
{
user:'user',
password: 'pwd',
host: 'localhost',
dbname: 'dbname'
}
db.query(sql [,params])
use Prepared Statements
$1
,$2
or?
return Promise<result> object
select * from table where id=?