google-suggest.js

0.0.2-d • Public • Published

This module promises an array with search suggestions from Google.

GoogleSuggest will automatically cache results to ./web/query.locale.json so that we do not piss off Google. GoogleSuggest utilizes EcmaScript6 features and I have properly commented it for those who want to learn.

Syntax

GoogleSuggest(query, locale)

Arguments

  • required (string) query: where to buy
  • required (string) locale: en

Use

/* Search suggesstions for 'where can I' in English */
let GoogleSuggest = require('google-suggest.js')
GoogleSuggest('where can I', 'en').then(suggestions => {
    console.log(suggestions)
}).catch(fail => {
    console.log(fail) // fail contains error message
})

The result

The resolved array looks like this.

[ 
    'where can i buy stamps',
    'where can i get a money order',
    'where can i buy dry ice',
    'where can i listen to lemonade',
    'where can i cash a check',
    'where can i buy borax',
    'where can i watch lemonade',
    'where can i cash a personal check',
    'where can i get a passport',
    'where can i watch the olympics' 
]
 

Related

You can find a PHP implementation using identical syntax here: https://github.com/jochemstoel/google-search-suggestions


Jochem Stoel

Involuntary public figure.

  • https://www.npmjs.com/~jochemstoel
  • http://jochemstoel.github.io/
  • https://jochemstoel.tumblr.com/
  • https://jochemstoel.nl/
  • https://www.facebook.com/Jochem-Stoel-271292656217087/

Package Sidebar

Install

npm i google-suggest.js

Weekly Downloads

0

Version

0.0.2-d

License

ISC

Last publish

Collaborators

  • jochemstoel