Skip to content

coire1/node-google

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js - google

build status

This module allows you to search google by scraping the results. It does NOT use the Google Search API. PLEASE DO NOT ABUSE THIS. The intent of using this is convenience vs the cruft that exists in the Google Search API.

This is not sponsored, supported, or affiliated with Google Inc.

js-standard-style

Installation

npm install --save google

API Example

This prints out the first 50 search results of the query node.js best practices.

var google = require('google')

google.resultsPerPage = 25
var nextCounter = 0

google('node.js best practices', function (err, next, links){
  if (err) console.error(err)

  for (var i = 0; i < links.length; ++i) {
    console.log(links[i].title + ' - ' + links[i].link) // link.href is an alias for link.link
    console.log(links[i].description + "\n")
  }

  if (nextCounter < 4) {
    nextCounter += 1
    if (next) next()
  }
})

You can also specify the TLD of the Google search page and the language.

var google = require('google')

google.lang = 'de'
google.tld = 'de'

google('node.js best practices', function (err, next, links){
  
})

You can specify the options to be passed to request, see the request module for all available options.

var google = require('google')

google.requestOptions = {
  proxy: 'http://user:[email protected]:80',
  timeout: 30000,
  localAddress: '127.0.0.1',
  jar: true,
  headers: {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'en;q=0.5',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'DNT': 1
  }
}

google('node.js best practices', function (err, next, links){
  
})

Contributors

License

Licensed under MIT. See LICENSE for more details.

Copyright (c) 2012-2015 JP Richardson

About

A Node.js module to search and scrape Google.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%